Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-10-2011, 09:17 AM   #1
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
using cut command

Hi all,

Assume that i am having a text file in my server, and it is wirtten like this


Hot to use cut command to echo the last value i.e.china in this case.

The values keep on increasing but i want only the last value every time.

How to acheive this, your suggestions would be very helpful.

Thanks in advance,
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-10-2011, 09:18 AM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Use 'tail -n1' not cut.
3 members found this post helpful.
Old 02-11-2011, 05:26 AM   #3
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
"cut" is useful when you are dealing with columns of data, in your case as pointed out by the previous post "tail" would be an easier option.
2 members found this post helpful.
Old 02-11-2011, 06:11 AM   #4
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Original Poster
Rep: Reputation: 18

Thanks that works.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
help with cut command using find. Cut last 8 characters leaving the rest ncsuapex Programming 4 09-16-2009 08:55 PM
How to use command grep,cut,awk to cut a data from a file? hocheetiong Linux - Newbie 7 09-11-2008 07:16 PM
finger and cut command Craig Bowes Linux - Newbie 3 10-09-2004 12:49 PM
Cut Command Help!! fooforon Programming 2 02-05-2004 10:09 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:38 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration