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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

editing number of csv files

Status
Not open for further replies.

rklad77

Technical User
Oct 2, 2003
5
US
Hi

I have got number of .csv files with two columns and more than 10000 rows. I need to truncate each file so that it only contains data from row 3 to row 700.
The edited file should be written with the same filename.
For example

File_01 is
1,20
2,25
3,30
4,35
-,--
similarly there are File_02,File_03 and so on.

Each file should be overwritten after editing.

Thanks in advance

Rohini
 
Quick method ...
Code:
for file in `ls File_*`
do
  head -700 $file|tail -698 > $file.tmp
  mv $file.tmp $file
done
Greg.
 
Try something like this:
Code:
for f in File_[0-9][0-9]; do
  echo '701,$d\n1,2d\nwq' | ex -s $f
done


Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top