|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Deleting line with sed command in unix/linux
Hello guys, I studied about this command but didn't tried and it is a screen shot to show you,how a sed command deletes the line from file. sed "/$textsearch/d" My_list will delete any line in the file My_list that matches $textsearch.I want to know how exactly i use this command to delete the line from the file so that it doesn't appear next time I open the file ? |
#2
| |||
| |||
Deleting line with sed command in unix/linux
This is one of the procedure through which you can delete particular line from the file.There are some options are being added with the command.The options are used to count and detect the number of lines. Code: (echo "g/${textsearch}/d"; echo 'wq') | ex -s My_list |
#3
| |||
| |||
Deleting line with sed command in unix/linux
I faced this situations,when I tried to execute the above written command and searched a lot of description but not getting success to execute without any help. On the other section of the search means beside of this code,I got a command which is able to delete the same and matching with the first posted thread but you have to do some little bit changes to before executing this command. sed "/$textsearch/d" My_list >tmp mv tmp My_list
__________________ Grand Theft Auto 4 PC Video Game |
#4
| |||
| |||
Deleting extraneous characters with sed command
You can delete the extraneous characters like <,*,#,@,etc.The file are full of these type of text and you want remove those extraneous characters from the file and when we open the file,the file should be looks like without any extraneous characters : You have to do some small changes in the code : Code: sed -n -e "s/^[^<]*<\([^>]*\)>.*/\1/p"
__________________ The FIFA Manager 2009 PC Game |
#5
| |||
| |||
Deleting line with sed command in unix/linux
Hi, This is one more example which can do this same means the deletion of extraneous characters on the command prompt.The command is combination of cut command. It would look same as the above suggested command by the expert members. $echo "Good Text<extraneous characters" | cut -d "<" -f1 Just specify the characters in the double court associated with cut command. |
#6
| |||
| |||
Re: Deleting line with sed command in unix/linux
Hi Fragman, use this command: sed -e "s/$textsearch//g" My_list > New_My_list where New_My_list will be ur new file name which contains all the content of the file My_list except those lines. Try this. Quote:
Last edited by nil_nilava : 20-03-2010 at 09:50 PM. |
![]() |
|
Tags: command, echo, linux, operating system, sed, unix |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Command Line in Linux to clear the /tmp folder | BBC123 | Operating Systems | 4 | 26-02-2012 02:41 PM |
How to perform Cut and paste from command line in Linux | Malik B | Operating Systems | 4 | 11-11-2010 04:12 PM |
Linux and UNIX shutdown command help | Morea | Operating Systems | 4 | 27-03-2010 09:32 PM |
Inroduction of Linux command line | Ceesar | Operating Systems | 5 | 31-12-2009 02:20 AM |
Download files from Linux command line | chaosblade | Operating Systems | 3 | 28-08-2009 03:18 PM |