Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Cut Command To Split File

Status
Not open for further replies.

thunderkid

Technical User
Oct 26, 2000
54
US
I am trying to format inputs from several processed files. I want to use cut command.

Current:
File1col1 File1col2 File1col3 File1col4

I have tried:
cut -f1,2 File1.dat > firstsec.dat
cut -f3,4 File1.dat > thirdfourth.dat

The files have space as a delimiters. As I have use Cut it is not separating the file.

thunderkid
 
I have solved my problem using awk. Thanks
thunderkid
 
The default field separator for cut is <Tab>, so you should play with the -d option.
The awk way is a good one as you don't need to read the file twice:
awk '{print $1,$2>"firstsec.dat";print $3,$4>"thirdfourth.dat"}' File1.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top