Reputation: 107
I have a CSV file with ;
delimiter:
3;85;2;8;9;5;8;6
7;4;5;6;2;2;4;6
I would like to have this output:
38528;9;5;8;6
7456;2;2;4;6
In general, I am trying to remove the delimiter from the three first columns.
Upvotes: 0
Views: 138
Reputation: 67507
hacky version of removing first three column delimiters:
sed -f <(echo "s/;//;"{,,}) file
Upvotes: 1
Reputation: 133518
try:
sed 's/;//1;s/;//1;s/;//1' Input_file
substitute semi colon on first position, then do the same operation 2 more times because one it will be done for example first position then second occurrence will become first semi colon then.
Upvotes: 0
Reputation: 203532
$ awk '{for(i=1;i<4;i++)sub(/;/,"")}1' file
38528;9;5;8;6
7456;2;2;4;6
Upvotes: 1
Reputation: 52142
In sed:
$ sed -E 's/([^;]*);([^;]*);([^;]*);/\1\2\3/' infile
38528;9;5;8;6
7456;2;2;4;6
This looks for and captures the pattern "a sequence of non-semicolons" followed by a semicolon, three times, and substitutes by the captured sequences not containing the semicolons.
Upvotes: 1
Reputation: 89557
With sed:
sed 's/;//;s/;//;s/;//' file
(replace ;
with nothing, 3 times)
Upvotes: 2
Reputation: 5533
awk approach
awk 'BEGIN{FS=OFS=";"} {print $1$2$3$4,$5,$6,$7,$8}' input_file
38528;9;5;8;6
7456;2;2;4;6
Upvotes: 3