sam786
1
I would like to filter out the following output:-
ps -ef | egrep "eurex|liffe"
./eurexPrice
/bin/sh
./eurexTrade
/bin/sh
/usr/bin/egrep
/bin/sh
/bin/sh
./eurexDaxTrade
/bin/sh
./eurexTrade_Tristan
./eurexTradeMM
0:05
And would like to have final output looking like this :-
eurexPrice
eurexTrade
eurexDaxTrade
eurexTrade_Tristan
eurexTradeMM
chella
2
Hi sam,
Using awk,
ps -ef | egrep "eurex|liffe" > out.txt
awk '/\.\// {sub("./","",$0);print $0;}' out.txt
You can do it using sed also
ps -ef | egrep "eurex|liffe" > out.txt
sed '/\.\//!d;s/\.\///g' out.txt
Both will give you the required output. First we need to take the lines which starts with ./ then replace ./ with nothing.
Regards,
Chella
sam786
3
Thanks,
How about this scenario :-
liffe_trade2
./eurexPrice
ksh
liffe_trade
liffe_price
/bin/sh
ksh
/bin/sh
./eurexTrade
ksh
Would like the output as :-
liffe_trade2
eurexPrice
liffe_trade
liffe_price
eurexTrade
-sam
Thanks
-sam
Assuming the list already exist;
list="liffe_trade2 ./eurexPrice ksh ..."
#!/bin/ksh
list=`echo $list | egrep "eurex | liffe"`
for item in $list
do
basename $item
done
OR simply
ps -ef | egrep "eurex|liffe" | egrep "eurex|liffe" | sed 's/.\///g'
BTW, what command that produce the earlier ouput ?