Find Word in Column with replace (2)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find Word in Column with replace (2)
# 1  
Old 05-03-2017
Find Word in Column with replace (2)

Dear ALL,

I have sample file :

Code:
4c:66:41:6b:b5:5f, 00:00,00:00, -22:-25, robert, 10.101.3.119, host1
4c:66:41:2c:c1:5a, 00:00,00:00, -21:-25, 10.101.3.112, host1
4c:66:41:6b:b1:5a, 00:00,00:00, -21:-25, Julia, 10.101.3.113, host1
4c:66:41:2c:c1:5b, 00:00,00:00, -21:-25, 10.101.3.115, host1
4c:66:41:6b:b1:5f, 00:00,00:00, -21:-25, Justin, 10.101.3.116, host1
4c:66:41:6b:b1:5c, 00:00,00:00, -21:-25, Fredy, 10.101.3.110, host1
4c:66:41:6b:b1:7a, 00:00,00:00, -21:-25, Josh, 10.101.3.123, host1

required output:

Code:
4c:66:41:6b:b5:5f, 00:00,00:00, -22:-25, robert, 10.101.3.119, host1
4c:66:41:2c:c1:5a, 00:00,00:00, -21:-25, anony, 10.101.3.112, host1
4c:66:41:6b:b1:5a, 00:00,00:00, -21:-25, Julia, 10.101.3.113, host1
4c:66:41:2c:c1:5b, 00:00,00:00, -21:-25, anony, 10.101.3.115, host1
4c:66:41:6b:b1:5f, 00:00,00:00, -21:-25, Justin, 10.101.3.116, host1
4c:66:41:6b:b1:5c, 00:00,00:00, -21:-25, Fredy, 10.101.3.110, host1
4c:66:41:6b:b1:7a, 00:00,00:00, -21:-25, Josh, 10.101.3.123, host1

Can you help me pls..

Help me please..

Thanks


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 05-03-2017 at 04:22 AM.. Reason: Added CODE tags.
# 2  
Old 05-03-2017
Code:
perl -nale '@F == 5 and splice @F,3,0, "anony,"; print "@F"' gnulyn.example

4c:66:41:6b:b5:5f, 00:00,00:00, -22:-25, robert, 10.101.3.119, host1
4c:66:41:2c:c1:5a, 00:00,00:00, -21:-25, anony, 10.101.3.112, host1
4c:66:41:6b:b1:5a, 00:00,00:00, -21:-25, Julia, 10.101.3.113, host1
4c:66:41:2c:c1:5b, 00:00,00:00, -21:-25, anony, 10.101.3.115, host1
4c:66:41:6b:b1:5f, 00:00,00:00, -21:-25, Justin, 10.101.3.116, host1
4c:66:41:6b:b1:5c, 00:00,00:00, -21:-25, Fredy, 10.101.3.110, host1
4c:66:41:6b:b1:7a, 00:00,00:00, -21:-25, Josh, 10.101.3.123, host1

This User Gave Thanks to Aia For This Post:
# 3  
Old 05-03-2017
Thanks Aia, my cese SOLVED.!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find Word in Column with replace

Hi ALL i have file.txt with text : 4c:66:41:6b:b5:5f, 00:00,00:00, -22:-25, users1, 10.101.3.119, host1 4c:66:41:2c:c1:5a, 00:00,00:00, -21:-25, 10.101.3.112, host1 4c:66:41:6b:b1:5e, 00:00,00:00, -21:-25, users1, 10.101.3.113, host1 4c:66:41:2c:c1:5b, 00:00,00:00, -21:-25, 10.101.3.115,... (3 Replies)
Discussion started by: gnulyn
3 Replies

2. Shell Programming and Scripting

Shell Script @ Find a key word and If the key word matches then replace next 7 lines only

Hi All, I have a XML file which is looks like as below. <<please see the attachment >> <?xml version="1.0" encoding="UTF-8"?> <esites> <esite> <name>XXX.com</name> <storeId>10001</storeId> <module> ... (4 Replies)
Discussion started by: Rajeev_hbk
4 Replies

3. Shell Programming and Scripting

Find number of characters in a column and replace

Hi all, I want to count total no. of characters in a column. and if no. of charaters are more than 3 then it must replace it by splitted string. ie, it must place a space after 3 characters. Ex: 21 435g asd3dd jklfjwe wer column number 3 has 4 alphanumeric character, so it must be splitted... (3 Replies)
Discussion started by: CAch
3 Replies

4. Shell Programming and Scripting

Help with replace column data with specific word

Input file: Populus_trichocarpa 30 0 50 0 0 US Vitis_vinifera 1 18 2 8 6 US Populus_trichocarpa 1 5 100 0 0 US Arabidopsis_lyrata_subsp._lyrata 0 90 0 0 0 US Glycine_max 0 2 3 0 70 UK Desired output file: Populus_trichocarpa YES NO YES NO NO US Vitis_vinifera YES YES YES YES YES US... (4 Replies)
Discussion started by: perl_beginner
4 Replies

5. Shell Programming and Scripting

Find and replace a word in all the files (that contain the word) under a directory

Hi Everyone, I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap". For Example: In the Directory, $pwd /home/nick $ grep -l "xsgd1234dap" *.sh | wc -l 119 I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies

6. Shell Programming and Scripting

simple Word Capitalization (Title) find/replace

Hi! I'm looking for a simple script, especially a one liner script in tcsh or bash that will emulate the find/replace in all text apps. I want to change all uppercase caracters to Title word (in wich only the first caracter is UpperCase and the rest is lowercase) I can use sed command, but... (2 Replies)
Discussion started by: sstpierre68
2 Replies

7. Shell Programming and Scripting

find replace a pattern and following characters in a word

Suppose that I have a string "one:#red two:#yellow three:#gr'een four:#blu^e" and I want to replace the pattern :# and the following characters in the word with nothing. The output string should look "one two three four" How can I do this with sed. Some points to consider (a) the last word in... (1 Reply)
Discussion started by: superuser84
1 Replies

8. Shell Programming and Scripting

find and replace in first column

Dear All I need help with find and replacing a string:.. In the following example of a file named say <filename.gff> with 9 columns 1 ensembl chromosome 1 300239041 . . . ID=1;Name=chromosome:AGPv1:1:1:300239041:1 1 ensembl exon 3 104 ... (3 Replies)
Discussion started by: cs_novice
3 Replies

9. Shell Programming and Scripting

Find and replace duplicate column values in a row

I have file which as 12 columns and values like this 1,2,3,4,5 a,b,c,d,e b,c,a,e,f a,b,e,a,h if you see the first column has duplicate values, I need to identify (print it to console) the duplicate value (which is 'a') and also remove duplicate values like below. I could be in two... (5 Replies)
Discussion started by: nuthalapati
5 Replies

10. Shell Programming and Scripting

Find and replace a part of the word in Shell

I have a csv file in which there are numbers like 078976/9XXX 098754/8XXX I want to replace the XXX with null. I want to know the command/code to do this. I know how to replace the whole word/number. But don't know how to replace a part of it. Thanks in advance, Mihir (3 Replies)
Discussion started by: mihirk
3 Replies
Login or Register to Ask a Question