Needed value after the last delimeter in a file with varying number of delimited columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Needed value after the last delimeter in a file with varying number of delimited columns
# 1  
Old 01-25-2012
Needed value after the last delimeter in a file with varying number of delimited columns

Hi All,
My file has the records as below:
Code:
aaa\bbb\c\dd\ee\ff\gg
zz\vv\ww
pp\oo\ii\uu

How can I get the value after the last delimeter.

My o/p:
Code:
gg
ww
uu

Thanks in Advance,

Last edited by Franklin52; 01-25-2012 at 07:58 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 01-25-2012
Code:
sed 's/.*\\\(.*\)/\1/' inputfile

There're several posts on this. Did you try searching the forum?
# 3  
Old 01-25-2012
Hi,
you can try with this
Code:
$ echo "xx\zz\yy"|awk -F\\  '{print $NF}'
yy

Code:
$ echo "xx\zz\yy\ss"|awk -F\\  '{print $NF}'
ss

thanks,
venkat

Last edited by Franklin52; 01-25-2012 at 08:51 AM.. Reason: Please use code tags for code and data samples, thank you
# 4  
Old 01-25-2012
Code:
cat file | awk -F'\' '{print $NF}'


Last edited by Franklin52; 01-25-2012 at 09:02 AM.. Reason: Please use code tags for code and data samples, thank you
# 5  
Old 01-25-2012
Quote:
Originally Posted by aksijain
cat file | awk -F'\' '{print $NF}'
awk (and sed) will both accept a filename as a parameter - you don't need cat.
Code:
awk -F'\' '{print $NF}' file

# 6  
Old 01-25-2012
Old habits die hard.. Can't get rid of this habit really Smilie

But I guess that code will work..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to change comma delimeter in the file to number?

I have a file H,20180624200732,VPAS,TRANS_HDR,20180724, VPAS.TRANS_HDR.20180724.01.txt, ,93, T,1, I have to change and instead first comma put ",1" like below H,20180624200732,VPAS,TRANS_HDR,20180724, VPAS.TRANS_HDR.20180724.01.txt,1,93, T,1, I made sed "2s/, /,1/"... (8 Replies)
Discussion started by: digioleg54
8 Replies

2. Shell Programming and Scripting

Modify comma delimited file columns.

Please help me to update a file which contains date values as below:- From:- "1912108",20161130,"2016-12-01-00.00.00.000000","2016-12-01-08.37.12.000000" "1912108",20161201,"2016-12-02-00.00.00.000000","2016-12-02-08.28.22.000000" To:- "1912108",2016-11-30,"2016-12-01... (7 Replies)
Discussion started by: KrishnaVM
7 Replies

3. Shell Programming and Scripting

Remove few columns from pipe delimited file

I have file as below column1|column2|column3|column4|column5| fill1|fill2|fill3|fill4|fill5| abc1|abc2|abc3|abc4|abc5| . . . . i need to remove column2,3, from that file column1|column4|column5| fill1|fill4|fill5| abc1|abc4|abc5| . . . (3 Replies)
Discussion started by: greenworld123
3 Replies

4. Shell Programming and Scripting

Awk print all columns in delimited file

text file example 1,222222222222,333,444444444444444 111111111,22,33333333,444 desired output 1 222222222222 333 444444444444444 111111111 22 33333333 444I have a delimeted file which I want to print in a table like format. The... (10 Replies)
Discussion started by: Calypso
10 Replies

5. Shell Programming and Scripting

missing comma delimeter in columns

hi if comma delimeter missing in columns treat them as bad file and if it is not then gudfiles. only checking columns not data. id,name,sal,deptno =======> gudfile 1,awa,200,10 2,aba,100,20 3,cdc,300,30 idname,sal,deptno ========> badfile since its missing (.)... (8 Replies)
Discussion started by: awais290
8 Replies

6. Shell Programming and Scripting

Read columns from delimited file in UNIX

Hello I need to read the columns from a flat file delimited by Hex code X02. The Sample file is Red^B1000^BJohn Blue^B2000^BSam Green^B3000^BDan Note: Hex code X02 shows as ^B in vi. I need to read the file and process the columns in each row. I tried using awk -F command but... (7 Replies)
Discussion started by: injey
7 Replies

7. Shell Programming and Scripting

Count the delimeter from a file and delete the row if delimeter count doesnt match.

I have a file containing about 5 million rows, in the file there are some records which has extra delimiter at random position. (we dont know the positions), now we have to Count the delimeter from each row and if the count of delimeter is not matching then I want to delete those rows from the... (5 Replies)
Discussion started by: Akumar1
5 Replies

8. UNIX for Dummies Questions & Answers

nth Columns in a Tab delimited file

Hi Can anyone help me to identify the nth field from a Tab delimited file? Thanks Subrat (8 Replies)
Discussion started by: subrat
8 Replies

9. Shell Programming and Scripting

Reading columns in tab delimited file

I want to read only one column in "|" delimited file and write that column to a new file. For Ex: Input File 1|abc|324|tt 2|efd|11|cbcb 3||1|fg 4|ert|23|88 Output : I want to read column 3 in diff file. 324 11 1 88 Can anyone give me inputs on this ? (2 Replies)
Discussion started by: net
2 Replies

10. Shell Programming and Scripting

Varying number of awk search strings

I've created an awk script that handles a varying number of search strings handed to it as command line parameters ($1 $2 etc). There may be 1, or 2 or 3 or more. A simplified version of the script is: awk -v TYP="$1 $2 $3 $4 $5 $6" ' BEGIN { CTYP = split (TYP,TYPP," ") } ... (2 Replies)
Discussion started by: CarlosNC
2 Replies
Login or Register to Ask a Question