Edit A Text File


Recommended Posts

I have a text file, I would like to edit. I am sure there must be an easy command to do it. Below is the contents of an example file called movielist.txt

incredibles.mp4
incredibles.mp4.conf
italian-job.mp4
italian-job.mp4.conf
jersey-girl.mp4
jersey-girl.mp4.conf
jungle-book-2.mp4
jungle-book.mp4
jungle-book.mp4.conf
killbill-vol2.mp4
killbill-vol2.mp4.conf
killbillvol1.mp4
killbillvol1.mp4.conf

I want to remove all lines that end with ".conf" I am trying to make a list that contains only movie files(.mp4)

Edited by shanenin
Link to post
Share on other sites

this line seems to work

sed '/.conf/d' movielist.txt > movielist2.txt

Is there a way to do it without having to create a new file, by directly changing the original file?

Edited by shanenin
Link to post
Share on other sites

that works nice :-)

edit added later//

I friend wanted a list of all of my movies on my harddrive. Here is the final command i ended up using

ls freevo/{movies,movies2} | sed -n '/\.mp4/p' > movielist.txt

that is like my 20th revisison ;-)

edit added later//

actaully I needed on more revision, the command above was also copying my movie.mp4.conf files that mplayer uses. I need to add a $

ls freevo/{movies,movies2} | sed -n '/\.mp4$/p' > movielist.txt

Edited by shanenin
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...