|
Let us see how to print the last field alone from a file which contains several fields.
Let's say that the input is the below file.
Now we need to Print the last field. i.e.
The required Output would be:
----------------------------------
7
4
8
8
We can do this by three ways.
1) The normal awk way of doing it:
$ awk 'BEGIN {FS=":"} {print $NF}' priority.txt
2) Using sed:
$ sed -n 's/.*://;p' priority.txt
3) Using grep:
$ grep -o '[^:]*$' priority.txt
0 Comments:
Post a Comment
Don't just read and walk away, Your Feedback Is Always Appreciated. I will try to reply to your queries as soon as time allows.
Note:
1. If your question is unrelated to this article, please use our Facebook Page.
2. Please always make use of your name in the comment box instead of anonymous so that i can respond to you through your name and don't make use of Names such as "Admin" or "ADMIN" if you want your Comment to be published.
3. Please do not spam, spam comments will be deleted immediately upon my review.
Regards,
Mohamed Abubakar Sittik A