Without using sed
or awk
, only cut
, how do I get the last field when the number of fields are unknown or change with every line?
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- JQ: Select when attribute value exists in a bash a
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
There are multiple ways. You may use this too.
Obviously, the blank space input for tr command should be replaced with the delimiter you need.
the following implements A friend's suggestion
Use a parameter expansion. This is much more efficient than any kind of external command,
cut
(orgrep
) included.See BashFAQ #100 for an introduction to native string manipulation in bash.
Without awk ?... But it's so simple with awk:
AWK is a way more powerful tool to have in your pocket. -F if for field separator NF is the number of fields (also stands for the index of the last)