bash: convert huge 2 col csv file to 1 col txt

Posted on 2013-12-02
Last Modified: 2013-12-03

Can you help me with the command to convert a huge csv file to a txt file.



TXT should bee like this (1st col from csv without double quotes)


Question by:netslt
LVL 14

Accepted Solution

jb1dev earned 500 total points
ID: 39690820
I assume that last line should be:

You can use
cat input.csv | sed 's/",".*//' | sed 's/"//'
LVL 19

Expert Comment

ID: 39691447
If you're just wanting to discard the quotes from the first value, and the second value entirely which is the way I understand it, then do this:

cat input.csv| cut -d, -f1 | tr -d '"' > input.txt

Open in new window

This way it will not matter if that missing quote pointed out by jb1dev is in some of the real input csv, or just a typo in the question - it will still do what you want.

Author Closing Comment

ID: 39691907
jb1dev has what I was looking for - works perfectly!

(xterm might also be right, have not tried....)


Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
linux redhat 7.2 10 89
android secure ftp 3 50
I am sending emails to my new email / server nothing is returned but nothing is received. 11 55
AWK: Pythagoras bp script 18 27
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question