I have the following csv file at the path; now using sed command. what is this exactly doing.
sed -i 's/[\t]/,/g' /FTP/LAB_RESULT_CM.csv
Thank you very much for the helpful info.
Most likely is trying to replace any tab for a coma.
However, in POSIX the RE bracket expression [\t] would try to match a literal back slash or a t character.
In any case there's no advantage to use it there:
The -i is replacing the original LAB_RESULT_CM.csv file with the result of the execution.
Last edited by Aia; 06-04-2017 at 08:59 PM..
Reason: Mentions the -i flag
Most likely is trying to replace any tab for a coma.
However, in POSIX the RE bracket expression [\t] would try to match a literal back slash or a t character.
In any case there's no advantage to use it there:
The -i is replacing the original LAB_RESULT_CM.csv file with the result of the execution.
As Aia said, the BRE [\t] will match a single <backslash> or lower-case letter <t> and the substitute command s/[\t]/,/g will replace each occurrence of either of those characters with a <comma>. But the POSIX BRE \t does not match a <tab> character; it matches exactly the same thing matched by the BRE t (i.e., just a lower-case letter <t>.
Some versions of sed, when not forced to operate in POSIX conforming mode, treat some backslash escapes in BREs as special and do recognize \n as a <newline> character, \t as a <tab> character, \b as a <backspace> character, \r as a <carriage-return> character, and \a as an alert (AKA <BEL>) character.
Since you haven't told us what operating system or version of sed you're using, we can't tell you which of several possible behaviors might occur on your system.
Similarly, the sed -i option is an extension to the standards. On some systems it will give you a syntax error for an unknown option. On some other systems it will perform in-place edits on the files named as operands (sometimes also creating a backup file if -i is given an option-argument. And on some other systems it might use case-insensitive matches when matching strings using REs.
The above differences between implementations are examples of why it is always a good idea to tell us what operating system, shell, and versions of tools you are using when you post a question like this.
This User Gave Thanks to Don Cragun For This Post:
Hi
I have a large csv file with lines like below
Date,Status,orig,dest,in,out,when,where
2012-01-01 00:30:37,I,48,56,23,98,83,34
2012-06-17 15:00:38,I,72,43,12,65,34,12I will really appreciate if someone can help with a sed script to transpose this to
2012-01-01 00:30:37,I,orig,48... (5 Replies)
Hello folks
I have a txt file of information about journal articles from different fields. I need to convert this information into a format that is easier for computers to manipulate for some research that I'm doing on how articles are cited. The file has some header information and then details... (8 Replies)
Hi,
I have a filename.csv in which there are 3 colums, ie:
Name ; prefixnumber ; number
root ; 020 ; 1234567
user1,2,3 ; 070 ; 7654321
What I want is to merge colum 2 and 3 that it becomes 0201234567 or even better +31201234567 so the country number is used and drop the leading 0.... (9 Replies)
Yes, there is a great doc out there that discusses parsing csv files with sed, and this topic has been covered before but not enough to answer my question (unix.com forums).
I'm trying to parse a CSV file that has optional quotes like the following:
"Apple","Apples, are fun",3.60,4.4,"I... (3 Replies)
I get a CSV file every day with 2 columns and multiple rows
ex:
date1,date2 ( both the fields are varchar fields)
This data has to be updated in a table which is being done manually and i want to automate that.
1. I have to select all the data from the prod table( 2 columns { date1,date2}) into... (4 Replies)
I am trying to remove the ita from this file:
"1234ita","john","smith"
"56789ita","jim","thomas"
the command i am using is:
sed '/^ita/d' infile.csv > outfile.csv
it is running but doing nothing, very rarely use sed so trying to learn it any help would be appreciated (2 Replies)
I have a an output file with a format:
something blah1.csv blah2.csv blah3.csv somethingelse
and I'm trying to use sed to pull all the *.csv entries out and put them 1 per line on a new file. I can't quite figure out how to write them to a new file with carriage returns, is there a simple way... (8 Replies)