how to remove all text including 2 certain character in each line!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to remove all text including 2 certain character in each line!
# 1  
Old 04-25-2011
how to remove all text including 2 certain character in each line!

Hi
I have a file which has aroun 200 line and it is like this:

Code:
GROUP2-WDI">GROUP2-WDI
GROUP3-WDI">GROUP3-WDI
KL2P0508BC">KL2P0508BC
KL2P0508BIT">KL2P0508BIT
KL3P0506BC">KL3P0506BC
KL3P0506BUS">KL3P0506BUS
KLD1F0507DBT">KLD1F0507DBT
KLD1F0507DIT">KLD1F0507DIT
KLD1F0510DBT">KLD1F0510DBT
KLD1F0510DIT">KLD1F0510DIT
KLD1P0510DBT">KLD1P0510DBT
KLD1P0510DIT">KLD1P0510DIT

what i want is to remove all plus "> in each line!
i want each line become like this:

GROUP3-WDI
# 2  
Old 04-25-2011
Code:
$ sed 's/.*">//' file
GROUP2-WDI
GROUP3-WDI
KL2P0508BC
....

# 3  
Old 04-25-2011
i bet you didn't know that you are awesome Smilie
# 4  
Old 04-25-2011
There's always more than one way to do it, cut should be a little bit faster:
Code:
cut -d">" -f2 infile

Code:
awk -F">" '{print $2}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove bracket including text inside with sed

Hello, I could not remove brackets with text contents myfile: Please remove the bracket with text I wish to remove: I tried: sed 's/\//' myfile It gives: Please remove the bracket with text A1 I expect: Please remove the bracket with text Many thanks Boris (2 Replies)
Discussion started by: baris35
2 Replies

2. Shell Programming and Scripting

sed - remove begin of line up to the third and including occurence of character

hello. How to remove all characters in a line from first character ( a $ ) until and including the third occurrence of that character ( $ ). Any help is welcome. (10 Replies)
Discussion started by: jcdole
10 Replies

3. UNIX for Dummies Questions & Answers

Remove last character in each line

Hi guys, Does anyone know how to remove the last character in each of the line? This is what I have: ABCDE.1 GLSJD.2 HIJPL.2 HKAGB.3 IUBWQ.1 What I want (remove the dot and number): ABCDE GLSJD HIJPL HKAGB IUBWQ I tried to use this: sed 's/.*//' But I'm not sure if that is... (3 Replies)
Discussion started by: narachaid
3 Replies

4. Shell Programming and Scripting

Remove the last character (,) for every line in a file

Good afternoon: im working wih 2 files to find differences and use the cmp command cmp file1 file2 file1 file2 are are diifferent char 302 line1 i found what the difference is with the sed command and that is the file1 at the end of every line has a (,) (comma) character. i.e sed -n... (4 Replies)
Discussion started by: alexcol
4 Replies

5. Shell Programming and Scripting

How to remove , if first character on line

Hi, I have a file with lines such as the below. I want to remove the comma only if it is the first character on a line. I can't work out how to do this using sed. *ELSET, ELSET=WHEEL_TD2 63, 64, 65, 72, 82, 88, 89, 92, 120, 121, 152, 181, 190, 221, 252, 259 , 260, 282, 283, 285, 286,... (2 Replies)
Discussion started by: carlr
2 Replies

6. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

7. UNIX for Advanced & Expert Users

To remove new line character

Hi, I am facing one interesting problem : I have a file which contains data like this 459,|1998-11-047|a |b |c \n efg | d|e | \n 459,|1998-11-047|a \n c|b |c \n efg | d|e | \n Basically what I have to do is , I have to remove all \n which is coming ( enclosed ) in between... (7 Replies)
Discussion started by: shihabvk
7 Replies

8. Shell Programming and Scripting

How do I remove everything after a certain character in text files?

I have a text file with a few thousand lines in the format: abcdef*ghijk*lmno pqrs*tuv wx*y*z etc. What I want to do is, get rid of everything after the SECOND asterik (the *) in each line (including the asterik). So for the example above, it would look like this after the editing: ... (11 Replies)
Discussion started by: guitarscn
11 Replies

9. Shell Programming and Scripting

How to use sed to remove html tags including text between them

How to use sed to remove html tags including text between them? Example: User <b> rolvak </b> is stupid. It does not using <b>OOP</b>! and should output: User is stupid. It does not using ! Thank you.. (2 Replies)
Discussion started by: alphagon
2 Replies

10. Shell Programming and Scripting

Remove Last Character of Line

Hi, I need to put the single line contents of a file into a variable, but remove the last character, for example the file would have this sort of contents: 2;4;3;10;67;54;96; And I want the variable to be: 2;4;3;10;67;54;96 (notice the last ";" has gone). Unfortunately I can't just... (4 Replies)
Discussion started by: danhodges99
4 Replies
Login or Register to Ask a Question