LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-13-2012, 12:40 AM   #1
tquang
Member
 
Registered: Jul 2010
Posts: 44

Rep: Reputation: 0
Cut string with command


Please help me.
I have string

95.108.155.252.35495
95.108.155.252.35496
95.108.155.252.3565
95.108.155.252.377
96.126.99.7.http
96.126.99.7.http
96.126.99.7.http

How can I cut bold string?
Thank you.
 
Old 03-13-2012, 12:52 AM   #2
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
Code:
cut -d. -f1-4 yourfile

Last edited by ruario; 03-13-2012 at 12:56 AM. Reason: made it shorter
 
1 members found this post helpful.
Old 03-13-2012, 12:55 AM   #3
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761Reputation: 1761
or with sed if you prefer:

Code:
sed 's/\(.*\)\..*/\1/' yourfile

Last edited by ruario; 03-13-2012 at 12:57 AM. Reason: stuck it in code tags
 
1 members found this post helpful.
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help to cut a string deepudixit Programming 5 11-28-2009 08:21 AM
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
how to cut first four digit of a string kkpal Linux - Newbie 3 07-22-2008 02:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:22 PM.

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