LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-07-2010, 02:09 PM   #1
macking
LQ Newbie
 
Registered: May 2010
Posts: 27

Rep: Reputation: 0
Simple Script


I am new to scripting, started this morning.

I want to run the following command in a script:

cat /etc/redhat-release

And have an if / then to return a result.

The script would run cat /etc/redhat-release, if it the system response was Red Hat Enterprise Linux Server release 5.1 (Tikanga) have the script return "RedHat5.1".

Can someone help me with this?

Thanks!
 
Old 07-07-2010, 02:18 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Code:
#!/bin/sh
S=`grep -c "Red Hat Enterprise Linux Server release 5.1 (Tikanga)" /etc/redhat-release`
if [ $S -eq "1" ]; then
 echo "RedHat5.1"
fi
 
1 members found this post helpful.
Old 07-07-2010, 02:21 PM   #3
macking
LQ Newbie
 
Registered: May 2010
Posts: 27

Original Poster
Rep: Reputation: 0
Troop, awesome, thank you. I can expound on this and actually get somewhere.

Thanks again!
 
Old 07-07-2010, 09:42 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,629

Rep: Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944Reputation: 2944
Please mark as SOLVED once you have a solution.
 
  


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
Need help getting started simple simple shell script dhonnoll78 Programming 6 12-17-2007 06:34 PM
Simple script to wait for another script Maverick1182 Linux - Newbie 4 11-05-2007 04:45 AM
Iptables (with masq) troubleshooting, very simple script attached script and logs. xinu Linux - Networking 13 11-01-2007 05:19 AM
Need help with a simple script shell script WindowBreaker Linux - Software 2 12-15-2005 01:45 PM
Simple C Shell script is not so simple elconde Programming 2 09-17-2001 12:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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