deleting text with sed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers deleting text with sed
# 1  
Old 07-20-2010
deleting text with sed

Hi There!

I've got a tab delimited text file (output from a software) to which I would like to delete specific strings from one of the columns. I have tried several sed codes, but they do not seem to work for me. I can manage to delete a specific word, but this is of no use, as I what I want to do is analogous to a e.g., "rm *jul10" to delete all files that start with "jul10" in a unix terminal. I have tried this code:
Code:
sed -e 's/c\w+//g' editfile.txt > editfile2.txt   #where c is the first character of the string you would like to delete (i followed a previous thread on this)

but it has not work. Something is printed on the terminal, but the output file is unmodified.

All help is welcome! Thanks!

Last edited by Franklin52; 07-21-2010 at 10:46 AM.. Reason: Please use code tags
# 2  
Old 07-21-2010
put sample input log and output you expect.
# 3  
Old 07-21-2010
try like this Smilie
Code:
 
# sed -e 's/c\w\+//g' editfile.txt > editfile2.txt

# 4  
Old 07-21-2010
Thanks for the input.
Code:
sed -e 's/c\w\+//g' editfile.txt > editfile2.txt

left the output file completely unchanged, which I find a bit bizarre. Any clues as to why this is happening?

Thanks.........

A

---------- Post updated at 04:58 PM ---------- Previous update was at 11:32 AM ----------

I got this to do the job, which deletes the number of characters equivalent to the number of dots after the "i" character.

Code:
sed -e 's#.i..............##g' fraglist2.txt > fraglist3.txt

I would like to get ygemici's command working. Seems a lot more versatile...Thanks!

Last edited by Franklin52; 07-21-2010 at 02:08 PM.. Reason: Please use code tags
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting [CR][LF] using sed

Dear all, I face a problem I can not solve: I have different lines in a file and some of them are ending with ie "\r\n" and the others are ending with "\n". My aim is to supress the string "\r\n" and concatenate that line with the following one. For example: Saying I have a file... (4 Replies)
Discussion started by: dae
4 Replies

2. UNIX for Dummies Questions & Answers

Deleting Block of Text from a File

Hi I am looking for the way to delete the block of data for example original file line1 line2 line3 line4 line5 input file line2 line3 original file should contain line1 line4 line5 (3 Replies)
Discussion started by: rakeshkumar
3 Replies

3. Shell Programming and Scripting

deleting text between two stings

example.txt ---------- this is a line i want to keep this is another line I wish to keep I wish to delete from here ON until I see four new lines from here and then I wish to keep the rest. These are some special charcters {)#@ which have to be deleted too This is a one more new line... (4 Replies)
Discussion started by: jville
4 Replies

4. Shell Programming and Scripting

deleting text records with sed (sed paragraphs)

Hi all, First off, Thank you all for the knowledge I have gleaned from this site! Deleting Records from a text file... sed paragraphs The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5... (1 Reply)
Discussion started by: Festus Hagen
1 Replies

5. Shell Programming and Scripting

Deleting lines using Sed

Hi All, Please can anyone help me as am deleting a line in a file with the below script: sed '/"$value"/d' redirects.virgin-atlantic.com.conf > olist where $value is a variable where the pattern to be matched is stored. I am not getting any error also but the line containing the pattern... (2 Replies)
Discussion started by: Shazin
2 Replies

6. Shell Programming and Scripting

sed logic before deleting

FileA NAME STATE CITY ---- ---- ----- abc ca ca bcc ny ny def nj nj (3 rows affected) Q1) I want to delete the second row with is ---- ---- -----. Can delete 2nd row using following sed '2d' FileA >FileB but incase the second record is not ---- ---- -----. then data will... (3 Replies)
Discussion started by: pinnacle
3 Replies

7. Shell Programming and Scripting

deleting text between ; and :

An ldif export needs some text removed from every line with a ; and : Only the text (including the ;) from the ; to the : (but not the :) needs to be removed. thoughts? here's an example of one record: dn: cn=me,ou=groups,dc=me,dc=com nsUniqueId: 1255060a-46e511dd-803ce5f5-385faa0b... (1 Reply)
Discussion started by: rfransix
1 Replies

8. Shell Programming and Scripting

Help deleting lines with SED.

I take the /etc/passwd file and print it out, but I only want the lines that end with sh. I have cat /etc/passwd | sed '/sh/!d' Which prints out all lines that have sh somewhere in it. So I added $, which I thought matches the ends on lines, but its not working, like for example I have have... (5 Replies)
Discussion started by: Bandit390
5 Replies

9. Shell Programming and Scripting

Deleting text block in file

Need to delete a text block inside a file, that is marked with a start and an end pattern. Eg do not delete not delete <tag1> delete everything here here and here and here... <tag2> do not delete do not delete.... Believe sed is able to do this job but don't get it working. ... (1 Reply)
Discussion started by: andre123
1 Replies

10. Shell Programming and Scripting

Deleting text from a file

Hi, In my korn shell script, I want to delete some particular text from a certain file...How can this be done? Is the below right? ed $NAMES << EOF echo "" > /dev/null echo "${x} = " > /dev/null echo "name = " > /dev/null echo "adress = " > /dev/null w q EOF (1 Reply)
Discussion started by: n8575
1 Replies
Login or Register to Ask a Question