Thread: find and remove

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    27
    Rep Power
    0

    find and remove


    Hi,

    Want to cycle through each single in a directory, remove all lines not containing |, write the ouput in a new and overwrite the old file with the new one.

    I have this code:

    Code:
    files=`find . -print | sort`
    for myfile in $files; do
       grep '|' $myfile > $OutFILE
       mv -f $OutFILE $myfile
    done
    but I am getting the following problems:
    • 1.) Displays the content of the file --> I don't want that
      2.) does nothing else


    Could someone please give an idea?

    Cheers,
    monaL
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    137
    Rep Power
    0
    LOL This question is crossposted: linux forum and here.

    Look at the linux forum, just posted your answer there.

IMN logo majestic logo threadwatch logo seochat tools logo