Results 1 to 2 of 2
Hi
I have a requirement like this:
Cut the characters from each line of a file with following positions:
21-24, 25-34 ,111-120.
These fields now need to be placed in ...
- 09-04-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 1
Pasting multiple cut outputs to a tab delimited output file
Hi
I have a requirement like this:
Cut the characters from each line of a file with following positions:
21-24, 25-34 ,111-120.
These fields now need to be placed in a tab delimited output file.
Currently this is how I am achieving it:
#!/bin/sh
cat newsmaple.txt | cut -c 21-24 > out1.txt
cat newsmaple.txt | cut -c 25-34 >out2.txt
cat newsmaple.txt | cut -c 111-120 >out3.txt
paste out1.txt out2.txt out3.txt >out.txt
rm out1.txt out2.txt out3.txt
cat out.txt
It does produce the required output but the code does not look clean. Is there a better way of doing this. Also I wish to avoid the 3 temporary outputfiles:
out1.txt out2.txt out3.txt .
Could you please help me on this.
- 09-04-2010 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
welcome to the forum
something like this might work
cut --output-delimiter="\t" -c 21-24,25-34,111-120 <newsmaple.txt >out.txtthe sun is new every day (heraclitus)


Reply With Quote