|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
To cut a string based on last index of identifier
here below is sample string Code:
null pointer dereference of 'resourceList' where null is returned from a method/opt/bld/fetch/ds/interzone/notification/LocalLineStatusNotificationListener.java:79 null pointer dereference of 'reList' where null is returned from a method/opt/bld/fetch/dunkindev6jbe4/src/com/ip/interzone/notification/LineStatusListener.java:45 i want to cut based on last index of '/' identifier. i tried Code:
cat fileName.txt | awk '.java' '{print $1}' | cut -d'/' f5but that would return only for partial since there are different number of '/' for each line.. so i need something to find last index of '/' and cut it and provide me only java file name |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
This will get you the filename: Code:
sed -e 's#.*/##' -e 's/:.*//' inputfile Or simply use grep: Code:
grep -o [^/]*java inputfile Last edited by Subbeh; 01-25-2013 at 05:53 AM.. |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Code:
awk -F'[/:]' '{print $(NF-1)}' file |
|
#4
|
||||
|
||||
|
Code:
awk '{gsub(/.*\/|:.*/,"")}1' file |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to cut based on a string | gvc | UNIX for Dummies Questions & Answers | 3 | 09-06-2012 04:54 AM |
| build array name based on loop index | janavan | Shell Programming and Scripting | 3 | 09-03-2012 07:33 AM |
| awk cut column based on string | Shirishlnx | Emergency UNIX and Linux Support !! Help Me!! | 15 | 02-15-2012 04:33 AM |
| error while extracting a line from a file based on identifier | vivek d r | Shell Programming and Scripting | 4 | 12-06-2011 04:07 AM |
| merging column from two files based on identifier | phil_heath | Shell Programming and Scripting | 4 | 06-12-2009 12:55 AM |
|
|