hyper link- abc:8081/xyz/2.5.6/rtyp-2.5.6.jar
Needs to get "rtyp-2.5.6.jar" i.e character after last backslash "/"
how to do this using sed/awk??
help is highly appreciated.
hyper link- abc:8081/xyz/2.5.6/rtyp-2.5.6.jar
Needs to get "rtyp-2.5.6.jar" i.e character after last backslash "/"
how to do this using sed/awk??
help is highly appreciated.
echo 'hyper link- abc:8081/xyz/2.5.6/rtyp-2.5.6.jar' | awk -F/ '{print $NF}'
thanks pravin u the master .
this site is excellent .hope i learn well from here.
once again thanks a ton
thanks pravin for quick & perfect reply. you genious.
hope i learn well more from this site.
once again hats off from a unix beginner
---------- Post updated at 02:42 PM ---------- Previous update was at 02:40 PM ----------
btw: can we do this similar thing using sed?? will help me in directly replacing in the file.
sed
echo 'hyper link- abc:8081/xyz/2.5.6/rtyp-2.5.6.jar' |sed 's:.*/::g'
OR
p='hyper link- abc:8081/xyz/2.5.6/rtyp-2.5.6.jar'
echo ${p##*/}
Using split method (Ruby1.9+)
$ echo "abc:8081/xyz/2.5.6/rtyp-2.5.6.jar" | ruby -e 'puts gets.split("/")[-1]'
rtyp-2.5.6.jar
Using regex
$ echo "abc:8081/xyz/2.5.6/rtyp-2.5.6.jar" | ruby -e 'puts gets.gsub(/.*\//,"")'
rtyp-2.5.6.jar
wow! ruby also looks good.
one issue facing is i have to do this in a file.
whose content is like
file.txt>>
anb/xrg/zxczxc.java
admin/WEB-INF/struts-config.xml
h-t-t-p://abc:8081/xyz/2.5.6/rtyp-2.5.6.jar
**h-t-t-p stands for hyperlink .not allowed to post them as of now
i need to cut only "http" lines with the jar names.
here its cutting all the lines & printing the last string after backslash.
$ ruby -ne 'puts $_.gsub(/.*\//,"") if /http/' file
rtyp-2.5.6.jar
$ ruby -F'/' -ane 'puts $F[-1] if /http/' file
rtyp-2.5.6.jar
Put your code in code tags next time