LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to delete certain lines from lots of files in the same directory? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-delete-certain-lines-from-lots-of-files-in-the-same-directory-774171/)

Thom_de_Rijk 12-08-2009 03:23 AM

How to delete certain lines from lots of files in the same directory?
 
Hello everyone,

I want to delete 2 lines from each file in a certain directory (and all subdirectories). I was wondering if there is a simple command to accomplish this.
Thanks for any help,
Thom

ghostdog74 12-08-2009 04:26 AM

what have you tried? hint: use find to find your files. as for deleting lines, there are variety of tools you can use, eg awk, sed , or even the shell.

action_owl 12-08-2009 05:41 AM

I recommend that you use a shell script with sed,

Give us some more information about what you're trying to accomplish and I'll help you out with the script.

Are you trying to delete lines at particular Line numbers? Do these lines have the same text in all files? please be specific.

pixellany 12-08-2009 07:17 AM

sed "$num,+1d" filename
(deletes 2 lines, starting with $num)


All times are GMT -5. The time now is 02:37 PM.