Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 12-27-2004, 02:21 AM   #1
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..
Old 12-30-2004, 01:01 AM   #2
Registered: Nov 2003
Location: Belgium
Distribution: Slackware
Posts: 182

Rep: Reputation: 25
just a suggestion

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


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 03:46 PM
grep command itz2000 Linux - Newbie 2 09-21-2005 07:06 PM
Develop grep command pengui Programming 1 10-16-2004 01:48 AM
Help With GREP Command juliettree Linux - Newbie 3 04-08-2004 08:44 AM
grep command cuss Linux - General 7 02-14-2003 09:23 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration