Tag Info

New answers tagged

2

First of all, less is just a pager, it is a tool that lets you read files. What you're doing is exactly the same as copying input_file to out_put.csv (cp input_file out_put.csv). You're not changing the content in any way. So, to read it as a spreadsheet using, for example libreoffice, you would need to open your spreadsheet application, then open your ...


2

Assuming you want to remove any cases of : followed by numbers from the 4th column (you say the 6th in your question but it's the 4th in your example), you can use one of these: awk awk -F';' -v OFS=";" '{sub(/\.[0-9]*$/,"",$6);}1;' file.csv > new.csv Perl (this changes the actual file and keeps the original as file.csv.bak) perl -i.bak -F';' -ane ...


1

To use python from the command line, you can check out pythonpy (https://github.com/Russell91/pythonpy): $ echo $'a,b,c\nd,e,f' | py '[x[1] for x in csv.reader(sys.stdin)'] b e


1

An awk solution: $ awk -F',' '$2 == 2 {$4 = "-"$4}1' OFS=',' file abc,0,def,1234,ijk xyz,2,def,-2345,abc ijk,2,def,-5678,ijl A perl equivalent: $ perl -F',' -anle '$F[3] = "-".$F[3] if $F[1] == 2; print join ",", @F' file



Top 50 recent answers are included