line="1234567890abcd"
This command will print out 1234567890
echo $line | awk '{print substr($0,1, length($0)-4)}'
This command will print out 0abcd
echo $line | awk '{print substr($0,length($0)-4)}'
Note:
substr( String, M, [ N ] ) Returns a substring with the number of characters...
Luckily my file won't contain any more than one dot.
I found some code involving awk, substr and length which I will have a look at and see if I can get it to work.
I'm from a VMS/DCL background and just starting in Unix Shell scripting. This sort of think is really easy in VMS/DCL.
wsFilePath="/myfile/tmp/ParList.dat"
wsFile=`basename $wsFilePath| cut -d. -f1`
this worked for me.
baseline returns the filename from the full filename and path. This is then piped through cut which splits the string by delimited . (That's the -d.) Field 1 is returned which is the filename...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.