Hi,
How to print last word of line?
#!/bin/bash
x1="This is Kiran"
echo "$x1"
how to print "Kiran" in new variable.i.e x2=kiran
Hi,
How to print last word of line?
#!/bin/bash
x1="This is Kiran"
echo "$x1"
how to print "Kiran" in new variable.i.e x2=kiran
x1="This is Kiran"
x2=`echo ${x1##* }`
echo $x2
Kiran
Another way..
x1="This is Kiran"
x2=`echo $x1|cut -d ' ' -f3`
There is always another way in Linux :
x1="This is Kiran"
x2= `echo $x1 | awk '{ print $NF }'
I guess no need of "echo" here.
x2=${x1##* }
Another way,
expr "$x1" : '.* \(.*\)'
Hi,
I have written one script :
#!/bin/bash
echo -n -e "\nEnter file name : "
read File
Temp=`find /apps12i -name $File`
echo "$Temp"
Output:
Enter file name : abc.log
/path1/abc.log
/path2/abc.log
I need script that should print "abc.log file present in multiple path"
so how do i compare "abc.log " ????
You should start new thread for different topic/issue.
Try something like...
Temp=`find /apps12i -name $File | wc -l`
if [ "$Temp" -gt 1 ]; then
echo "abc.log file present in multiple path"
fi
Ok.thanks