Exclude specific word from input file problem asking...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exclude specific word from input file problem asking...
# 1  
Old 05-04-2010
Exclude specific word from input file problem asking...

Hi,
Below is my input file and desired output file:
Input file:
Code:
>header_N_1
ASFDGDGNDGEGWETWRYWTETWNETOWETWETWNETTETNWET
.
.

Desired output file:
Code:
>header_N_1
ASFDGDGDGEGWETWRYWTETWETOWETWETWETTETWET
.
.

From the input file, I just hope to exclude the 'N' word from its content without effect the header content.
Thanks for any advice.
# 2  
Old 05-04-2010
Code:
awk '!/header/ {gsub(/N/,""); print; next}1' file

# 3  
Old 05-04-2010
Thanks zaxxons,
your awk code work perfectly in my case.
Thanks again for sharing Smilie
# 4  
Old 05-04-2010
Code:
sed '1n;/N/s///g' file

# 5  
Old 05-04-2010
A sed solution for the case where a header may occur outside the first line of the file:
Code:
sed '/^>header/!s/N//g' file

Regards,
Alister
# 6  
Old 05-16-2010
Quote:
Originally Posted by zaxxon
Code:
awk '!/header/ {gsub(/N/,""); print; next}1' file

Code:
awk '!/^>/ {gsub(/N/,"")}1' urfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

2. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 Replies

3. UNIX for Advanced & Expert Users

Exclude dash (-) from word separators in vi

vi uses dash and space as word separators. is there any way to exclude dash from word separators ? This is required to work with the symbols generated by ctags exe. when symbol contain a "-" ,vi tags fails to locate that even though symbol is generated properly. For example Symbol -... (3 Replies)
Discussion started by: cabhi
3 Replies

4. UNIX for Dummies Questions & Answers

How to print the specific word in a file.

Hi , My input file is below like that :- $cat abc.txt Service name: test_taf Service is enabled Server pool: test_tac Cardinality: 2 Disconnect: false Service role: PRIMARY Management policy: AUTOMATIC DTP transaction: false AQ HA notifications: true Failover type: SESSION... (3 Replies)
Discussion started by: sp001
3 Replies

5. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

Hi, I have gone through may posts and dint find exact solution for my requirement. I have file which consists below data and same file have lot of other data. <MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'> <MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
Discussion started by: tmalik79
11 Replies

6. Shell Programming and Scripting

Check a specific word whether is in file

I want to valid a specific word whether it is contained in the text file. For example: family.txt father mother son sister if ("father" contain in family.txt) do some process else do other process How shell scripting can accomplish this? Anyone can provide helps? (3 Replies)
Discussion started by: alvin0618
3 Replies

7. Shell Programming and Scripting

Find a word in input file

Hi, I had a input file containing, abcdefghij;20100903040607;1234567891;GLOBAL; abc123;20100903040607;12345;09;thestdf; def456;20100903040607;67891;04;bnkim; I need to search word GLOBAL in my file. If it is found then do something else do other thing How can i write if loop for... (13 Replies)
Discussion started by: Poonamol
13 Replies

8. UNIX for Dummies Questions & Answers

Search a specific word from any one of the file.

how do i Search a specific word from any one of the file.? (1 Reply)
Discussion started by: ritusubash
1 Replies

9. Shell Programming and Scripting

Remove specific word from data contents problem asking

Hi, Below is my input file: >tempZ_1 SAFSDAFDSG GGERRTTZZZ ZASRARARET WETPOASDAZ ZZZASASFAS >temp_9 ASAEGPIOEO EIOPIZZZAS FDFGZZZARA ESEAZZZAAS . . Desired output file: (9 Replies)
Discussion started by: patrick87
9 Replies

10. Shell Programming and Scripting

Reading specific contents from 1 input files and appending it to another input file

Hi guys, I am new to AWK and unix scripting. Please see below my problem and let me know if anyone you can help. I have 2 input files (example given below) Input file 2 is a standard file (it will not change) and we have to get the name (second column after comma) from it and append it... (5 Replies)
Discussion started by: sksahu
5 Replies
Login or Register to Ask a Question