I may be making this too hard on myself, but I'm trying to find a way that I can use a cut or awk string to always remove the last two delimited fields of a string.
Say I have
PackageName-U939393-8.2.3.4.s390x.rpm
But the s390x could be any string w/o periods in it, x8664 for example, etc... I need to use cut or awk to remove the .s390x.rpm piece.
I was using '.' as the delimiter, but the number of '.' will vary.
NF is an internal variable that specifies Number of Fields. You can then access the last field as $NF, second to last as $(NF-1) etc.
Here I just decrement NF by two and set the OFS (output field separator) to '.'. The '1' is a shortcut for 'print $0'.
That is what i tough. Even for leaving out the 1 cause the default action is print $0 but i was only wondering what is reasoning was for putting a ; into those brackets.
Thanks for all the responses, I went the awk route before the other ones and the awk one definitely works. Haven't tested the others, but I'll probably use the shell only one, just b/c that's what I generally do and it should be faster.