LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-01-2011, 10:34 PM   #1
caliiluvv
LQ Newbie
 
Registered: Mar 2011
Posts: 1

Rep: Reputation: 0
Urgent


I have a big file called the game, and want to find all the lines that do NOT have the word "shozbot" in it, and I want to sort them alphabetically, and save that in a file called "squiggy". How would I do that in one line of commands?


Thnks
 
Old 03-01-2011, 10:42 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 165Reputation: 165
Sorry, but it's hard to take your post seriously - with a subject of urgent and a task that sounds like it was made up... What have you done so far and what specific problem are you having?
 
0 members found this post helpful.
Old 03-02-2011, 08:29 AM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 377Reputation: 377Reputation: 377Reputation: 377
Seriously, pick a more appropriate title for your post next time.

As for the command, here's a basic example (you'll need to add options depending on your requirements):
Code:
grep -v shozbot game.txt | sort > squiggy.txt

Last edited by win32sux; 03-02-2011 at 08:30 AM.
 
Old 03-02-2011, 08:45 AM   #4
devUnix
Member
 
Registered: Oct 2010
Location: Bengaluru, India
Distribution: RHEL 5.1 on My PC, & SunOS / Sun Solaris, RHEL, SuSe, Debian, FreeBSD and other Linux flavors @ Work
Posts: 584

Rep: Reputation: 59
Win32sux has answered your question.

I give you some explanation here.

Code:
grep -v "pattern" fileName
prints lines that do not caontain the "pattern". If the "pattern" is not found at all then all the lines are printed.

Remove the -v option and it will print only those lines that contain at least one match of the "pattern".

So,

Code:
grep -v "shozbot" game
will print any line that does not contain "shozbot".

Next, we pipe this output to the sort command which displays the sorted lines:

Code:
grep -v "shozbot" game | sort
Finally, we redirect the sorted output to a named file:

Code:
grep -v "shozbot" game | sort > squiggy
Check it out!
 
  


Reply


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
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 11:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 09:07 PM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 03:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration