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 06-23-2012, 06:03 PM   #1
LinuxChiq
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Rep: Reputation: Disabled
Grep is missing the command -A ?


I wrote a script that has this in the file

grep -A 1 'Release' earning.*

but when I ported it to another machine running centOS, it gave me


./earnings.sh: line 10: -A: command not found



How come -A is available on one machine, but not the other?

More importantly, how do we fix this?
 
Old 06-23-2012, 06:18 PM   #2
LinuxChiq
LQ Newbie
 
Registered: Dec 2011
Posts: 5

Original Poster
Rep: Reputation: Disabled
When I ported over to the new machine, it did not have the grep command. therefore the machine was reading

-A 1 'Release' earning.*


instead of

grep -A 1 'Release' earning.*

doh!
 
Old 06-24-2012, 12:29 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
This whole thing sounds strange. First of all, grep is a basic, low-level, posix-defined tool that start-up scripts often depend on, and should always be installed as part of the core system.

Second, it seems odd that it would error on the -A. Just because the command doesn't exist doesn't mean that the command word would be ignored. It should be saying something like "grep: command not found" instead.



BTW, you should also be aware that while Linux distros generally use the gnu versions of the basic system toolset, other unixes have their own implementations of them, and these often have different, and sometimes more limited, command options. You have to be quite careful when porting scripts between different types of systems.
 
  


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
[SOLVED] run ps|grep command by script/command line ... ERROR: Unsupported option (BSD syntax) masuch Programming 4 05-23-2012 05:13 AM
How to pass the result of a command to another command (like grep) desb01 Programming 4 06-25-2009 01:09 PM
using grep command hiteshthappa Linux - Newbie 4 07-11-2008 09:34 AM
Help me in Grep Command + cd command in single line JeiPrakash Linux - Newbie 3 05-27-2008 05:16 AM
grep command karimasif Linux - Newbie 2 09-05-2007 12:54 PM

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

All times are GMT -5. The time now is 08:55 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