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!

Working with multiple files (newbie) 1

Status
Not open for further replies.

mare99

Technical User
Sep 15, 2005
2
DE
Hi,

I have a lot of files in one directory, for example:

first file looks like this:

t51 21 1 57
t51 41 2 57


second, third... files all look similar. Their names are all different, except they end on .dat

What want to do is to open each file, only print column 2 and 3 and then save it with the same filename. The first file would then look like:

21 1
41 2


Probably this is a simple task?
 
A starting point:
for f in *.dat
do awk '{print $2,$3}' $f > $f.tmp && mv $f.tmp $f
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thx.

That was really fast!!

Jesus!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top