Hi i have an input " load /appss/asdfas/...
I want to take the string present between first / / i.e appss
Input is "load /appss/asdfas/..."
Expected output is appss
Thanks in advance
Ananth
Hi i have an input " load /appss/asdfas/...
I want to take the string present between first / / i.e appss
Input is "load /appss/asdfas/..."
Expected output is appss
Thanks in advance
Ananth
# echo "load /appss/asdfas/..." | awk -F'/' '{print $2}'
appss
# x="load /appss/asdfas/..."
# t=${x#*/};echo ${t%%/*}
appss
with cut ..
$ echo "load /appss/asdfas/..." | cut -d'/' -f2
with sed ...
echo "load /appss/asdfas/..." | sed 's![^/]*/!!;s!/.*!!'
I have a file which has
element * CHECKEDOUT
element \fiosapp\... .../ch_connectedhome/LATEST
element \fiosapp\... /main/LATEST -mkbranch ch_connectedhome
load \fiosapp\ConnectedHome
load \fiosapp\ConnectedHomeProject
load \fiosapp\Build
when i use the command `cat FILE_NAME |grep load |awk -F'\' '{print $2}'`
ConnectedHome
ConnectedHomeProject
Build
are getting printed but i want "fiosapp" to get printed. What do I do??
Thanks
Ananth
Try
# awk -F'\' '/load/ {print $2}' FILE_NAME
fiosapp
fiosapp
fiosapp
EDIT: But I get that output even with your supplied command. What does the output of your grep command look like? What shell are you using?
awk -F\\ '/load/ {print $2}' FILE_NAME
FILE_NAME looks like a variable name, mayb you need the heading $ ---> $FILE_NAME
?
Hi carlom
It is working fine. The file had some other text previously so it didnt work. Now it is working. thank you
Ananth
---------- Post updated at 08:54 AM ---------- Previous update was at 08:41 AM ----------
hi
I need to print once only if the output is same. In the above case i need to print fiosapp once since it is same and in the below case
element * CHECKEDOUT
element \fiosapp\... .../ch_connectedhome/LATEST
element \fiosapp\... /main/LATEST -mkbranch ch_connectedhome
load \fiosapp\ConnectedHome
load \fappa\ConnectedHomeProject
load \fasdfg\Build
I need to print fiosapp fappa fasdfg
Thanks
awk -F'\' '/load/ {print $2}' FILE_NAME | sort -u
or
awk -F'\' '/load/ {print $2}' FILE_NAME | uniq
(which do slightly different things, depending on whether you want to remove all duplicate names, or just consecutive ones)