LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 12-27-2004, 03:21 AM   #1
alnreddy
LQ Newbie
 
Registered: Nov 2004
Posts: 29

Rep: Reputation: 15
Unhappy grep command in c?????


hi ,
I want to redirect output of a c program in other c program.
Here i want to use grep command in c to filter the output to the desired.
Can i do it?
I will be more clear.
I want a command to run and then the output to be redirected .
if i run the command, , i will get the details about the hard disk.
But i just want the output to be Serial number and all that is not needed.
So, i am planning to use grep command to rediract that output.
so, i have written a c program like this:
System("/sbin/hdparm -i /dev/hda ")
This will get the entire details.
now, the command,/sbin/hdparm -i /dev/hda | grep "Serial Number" will give me just the serial number of the hard disk.
For this , i want to use grep with a pipe in c program.
I tried it in "System". It didint work out.
Is there any possibility that i can use grep command in c.
????
Need help.
Looking forward for reply..
Narasimha
 
Old 12-30-2004, 02:01 AM   #2
tlowk
Member
 
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 151

Rep: Reputation: 23
just a suggestion

System("bash -c \"/sbin/hdparm -i /dev/hda | grep Ser\"")
 
  


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
how to use grep command sharonyiisl Linux - Newbie 7 05-28-2006 04:46 PM
grep command itz2000 Linux - Newbie 2 09-21-2005 08:06 PM
Develop grep command pengui Programming 1 10-16-2004 02:48 AM
Help With GREP Command juliettree Linux - Newbie 3 04-08-2004 09:44 AM
grep command cuss Linux - General 7 02-14-2003 10:23 AM


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