LinuxQuestions.org
Help answer threads with 0 replies.
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 12-01-2011, 05:09 AM   #1
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,740

Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Question I want to extract names with spaces from a list of names!


Hi.

I have a large list of names. How can I find names with a space e.g. Ozzy Lebron or Mars Leucetius etc.?
Could I extract names like that and copy them into a 2nd text file titled "names2.txt"

Thanks.
 
Old 12-01-2011, 05:31 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You should include some sample lines of input. How are the full names delimited?
 
Old 12-02-2011, 02:53 AM   #3
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,740

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Lightbulb

Quote:
Originally Posted by jschiwal View Post
You should include some sample lines of input. How are the full names delimited?
They are in a list from a .txt file.

Sample:
Ozzy Lebron
Azia
Aziel
Azima
Aziza
Azizah
Azize
Azmariah
Azmik
Azra
Azrael
Azrakesh
Azriel
Azucena
Azuka
Azura
Azure
Azuriah
Azurine
Azusa
Azusena
Azzam
Azzaria
Azzure
Bab
Babak
Babette
Bac
Backstere
Bader
Badi
Baecere
Mars Leucetius
 
Old 12-02-2011, 03:02 AM   #4
trey85stang
Senior Member
 
Registered: Sep 2003
Posts: 1,091

Rep: Reputation: 41
Code:
sed "/ / ! d" filename.txt
 
1 members found this post helpful.
Old 12-02-2011, 05:46 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I didn't know you had one name per line in your list. Thank you for the clarifying example. Regular expressions can be very finicky about how the input is formatted.

Last edited by jschiwal; 12-02-2011 at 05:47 AM.
 
Old 12-02-2011, 09:42 AM   #6
linustalman
LQ Guru
 
Registered: Mar 2010
Location: Ireland
Distribution: Debian 12 Bookworm
Posts: 5,740

Original Poster
Rep: Reputation: 479Reputation: 479Reputation: 479Reputation: 479Reputation: 479
Thumbs up

Quote:
Originally Posted by trey85stang View Post
Code:
sed "/ / ! d" filename.txt
Excellent work!
 
  


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
du or wc and file names with spaces bramadams Slackware 2 01-27-2005 11:43 AM
files that have spaces in their names hesher Linux - Software 5 01-14-2005 01:43 PM
Spaces in file names JohnKFT Slackware 3 11-09-2004 03:44 PM
directory-names with spaces... Schmurff Linux - Newbie 2 03-07-2004 11:06 AM
Files with spaces in their names downinthemine Linux - General 3 12-12-2003 01:48 PM

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

All times are GMT -5. The time now is 07:30 AM.

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