![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting only directory not files | manoj.solaris | Linux | 13 | 05-02-2008 05:24 AM |
| deleting lines from multiple text files | vrms | Shell Programming and Scripting | 3 | 04-25-2008 08:01 AM |
| Deleting Lines from .CSV Files | 009satya | Shell Programming and Scripting | 1 | 11-13-2006 12:30 PM |
| Deleting specific lines in a file | ramu_1980 | Shell Programming and Scripting | 4 | 02-15-2005 10:41 AM |
| Deleting specific files greater then 90 days | beilstwh | Shell Programming and Scripting | 2 | 07-22-2004 12:27 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
deleting specific lines from all files in a directory
I have a directory full of text data files.
Unfortunately I need to get rid of the 7th and 8th line from them all so that I can input them into a GIS application. I've used an awk script to do one at a time but due to the sheer number of files I need some kind of loop mechanism to automate it. The awk script used: - awk 'BEGIN{getline f;getline t}FNR==f,FNR==t{next}1' numbers.txt inputfile > outputfile where numbers.txt is merely a document with the numbers 7 and 8 My guess is that I need a way of piping the output from ls (of the directory) into where the inputfile is situated and a counter to loop through till the end. Any suggestions will be welcome (an awk suggestion would be preferable to pearl) Thanks all |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
for f in *; do awk 'NR!=7 && NR!=8' "$f" >"$f.tmp" mv "$f.tmp" "$f" done ls has no particular use here; it's the shell which expands wildcards, not ls. |
|
#3
|
|||
|
|||
|
worked a charm
Thanks esa cheers |
|
#4
|
|||
|
|||
|
oops sorry
era I mean cheers |
|||
| Google The UNIX and Linux Forums |