Delete Word between two Char.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Delete Word between two Char.
# 1  
Old 09-05-2014
Delete Word between two Char.

HI Guys,

I have Input:- A


nput A.txt

Code:
000100/port_xcu_dev_6/port_0_dev_7              
000100/port_xcu_dev_6/port_1_dev_10             
000100/port_xcu_dev_2/port_2_dev_8              
000100/port_xcu_dev_3/port_3_dev_11             
000100/port_xcuv_9/port_4_dev_9              
000100/port_xcu_6/port_5_dev_12

Output B.txt

Code:
000100/port_0_dev_7 
000100/port_1_dev_10
000100/port_2_dev_8 
000100/port_3_dev_11
000100/port_4_dev_9 
000100/port_5_dev_12

# 2  
Old 09-05-2014
Hello Pareshkp,

Following may help.

Code:
 awk -F"/" '{print $1 OFS $3}' OFS="/"  filename > Output_file

Output will be as follows.

Code:
cat Output_file
 
000100/port_0_dev_7
000100/port_1_dev_10
000100/port_2_dev_8
000100/port_3_dev_11
000100/port_4_dev_9
000100/port_5_dev_12

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 09-05-2014
Thanks
# 4  
Old 09-05-2014
Or using sed:
Code:
sed 's#/[^/]*##' file

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete word from the file

My file has contents like below. It is named as output_file.txt /usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_2015-08-27_tmptcmsaslva2_19142.log /usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_2015-08-27_tmptcmsaslva2_19142.log... (12 Replies)
Discussion started by: Ram Kumar_BE
12 Replies

2. Shell Programming and Scripting

Delete Last Char from first World

HI File A.txt Abcde12351 Kalel Abcde12962 Basil Abcde21653 Fosil Output B.txt Abcde1235 Abcde12351 Kalel Abcde1296 Acbde12962 Basil Abcde2165 Acbde21653 Fosil Thanks (1 Reply)
Discussion started by: asavaliya
1 Replies

3. Shell Programming and Scripting

Search the word to be deleted and delete lines above this word starting from P1 to P3

Hi, I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this: Records P1 10,23423432 ,77:1 ,234:2 P2 10,9089004 ,77:1 ,234:2 ,87:123 ,9898:2 P3 456456 P1 :123,456456546 P2 abc:324234 (2 Replies)
Discussion started by: vsachan
2 Replies

4. Shell Programming and Scripting

Delete everything after/before a word in a file

I'm looking for a command that will read a file listing information and delete everything after a certain word is found. I also may need to search the file and delete everything before a certain word. The file would contains fields of information like below repeating for the entire file; Name... (5 Replies)
Discussion started by: daveisme
5 Replies

5. Shell Programming and Scripting

Delete character from a word

Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp : I want to replace "20091001" by "091001" or "replace" by "place" Thx, (13 Replies)
Discussion started by: newpromo
13 Replies

6. UNIX for Dummies Questions & Answers

delete first two " char

Hi, I need to delete the char " from a line but only the first 2 example: JPY,0,XS0122118481,CCDO,IFI_CCDO,"2,210,000,000","2,210,000,000",0.00 result: JPY,0,XS0122118481,CCDO,IFI_CCDO,2,210,000,000,"2,210,000,000",0.00 How may I go about doing this? Thanks (2 Replies)
Discussion started by: UNovIX
2 Replies

7. UNIX for Dummies Questions & Answers

Delete a word

i have created the following input script CREATE OR REPLACE VIEW MMSSENDAVGUPLOADTIME_GN AS sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_val sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_counter select... (1 Reply)
Discussion started by: gseptember
1 Replies

8. UNIX for Dummies Questions & Answers

How to delete all character before certain word

Hi, For example, i have a string "123 456 789 abc 111 222 333" and I would like to delete all the characters before abc so that it becomes "abc 111 222 333" how can i do that in unix? using sed? note: I actually don't know how many words/charachters before "abc", so the "cut"... (9 Replies)
Discussion started by: phandy
9 Replies

9. Shell Programming and Scripting

sed - delete until char x

Hi, I got a Textfile contains hundreds of lines like this: 3 02 8293820 0 22 22 All I need is this: 293820 0 22 22 So i decided to delete until the first '8' comes up. But how I can realize that? (9 Replies)
Discussion started by: mcW
9 Replies

10. Shell Programming and Scripting

How do I count # of char. in a word?

I havent done shell scripting in quite some time. I want to know how to count the number of characters in a word, specifically a parameter. Example: myscript hello I want "myscript" to return the number of charcaters in the parameter "hello". Any ideas? (9 Replies)
Discussion started by: xadamz23
9 Replies
Login or Register to Ask a Question