Re: using linux commands in C++ code
I don't have that much Linux experience but I doubt that it will be any significant change in speed. After all redirecting the output using the > is pretty much the same thing as redirecting it using code. Anyway, if you want to test it adding those lines in main() should be sufficient.
Re: using linux commands in C++ code
Alright. Thanks S_M_A. Let me try this.
Re: using linux commands in C++ code
S_M_A it worked in C++ code and was much faster than it was when written explicitly on command line :). Thanks
Re: using linux commands in C++ code
Someone suggested me this example "http://www.cplusplus.com/reference/iostream/ios/rdbuf/" which I found a bit easier and it worked as well but not when I tried to use it with the output of this command
Code:
system("diff /home/test1.txt /home/test2.txt");
Do you have any idea why? it still prints the output on to the screen and not to a file.
Re: using linux commands in C++ code
Hm sounds like a system call does not run in an exact copy of the parent process environment. Amazing also that there was a difference. You learn something new every day... :)
I guess you could change the diff call to redirect the output? Try that and I'll browse around abit to check if there's some other way to do it.
Re: using linux commands in C++ code
Thanks S_M_S
could you please write to me a line of code for changing the diff call to redirect the output?
Re: using linux commands in C++ code
Nope, I didn't find any new info regarding this. :(
You redirect just as you've done before by using > on the command line.
Re: using linux commands in C++ code
Alright Thanks a lot any way.
I have just found a code which is I think written in perl. Could you please tell me the meaning of each of these lines because I ran this code and it worked exactly what I needed
Code:
#!/bin/bash
counter=1
exec 3< /usr/local/test1.txt
while read -u3 line
do
grep "$line" /usr/local/test1.txt2>/dev/null
if [[ $? -eq 1 ]]
then
echo "Line $counter is not present in Naginas_Exp_0206_non_dupCME file!!!"
fi
(( counter += 1 ))
done
Re: using linux commands in C++ code
Quote:
Originally Posted by
heidiK
Alright Thanks a lot any way.
I have just found a code which is I think written in perl. Could you please tell me the meaning of each of these lines because I ran this code and it worked exactly what I needed
Code:
#!/bin/bash
counter=1
exec 3< /usr/local/test1.txt
while read -u3 line
do
grep "$line" /usr/local/test1.txt2>/dev/null
if [[ $? -eq 1 ]]
then
echo "Line $counter is not present in Naginas_Exp_0206_non_dupCME file!!!"
fi
(( counter += 1 ))
done
That's a bash script, not PERL. Just type 'man bash' on your *NIX terminal.
Viggy
Re: using linux commands in C++ code
Re: using linux commands in C++ code
Here you can check out the most used linux commands .