akkad Posted August 6, 2007 Share Posted August 6, 2007 hi every body: when i am runing this commands: <code> ls `find ./logs -name access.log.*` -l | grep May | awk ' {print $9}' ./logs/access.log.81 ./logs/access.log.82 ./logs/access.log.86 </code> now i want to send the output of this command to cat command: <code> cat `ls `find ./logs -name access.log.*` -l | grep May | awk '{print $9}'`` > </code> i am getting just this > symbol , so how i can redirect the output to the cat command. Quote Link to comment Share on other sites More sharing options...
trq Posted August 6, 2007 Share Posted August 6, 2007 Why would you want to do this? Can you explain what your trying to do exactly? Quote Link to comment Share on other sites More sharing options...
neylitalo Posted August 6, 2007 Share Posted August 6, 2007 Um... running cat on this particular command will just return the output, why can't you leave the cat out? Quote Link to comment Share on other sites More sharing options...
akkad Posted August 7, 2007 Author Share Posted August 7, 2007 ok let met explain the problem from begining : in my page i have forms that allow the user to chose the report month and year and when the user will submit that the page will bring a full report of his traffic on that time. what i want to do is that : when the user will chose the month the code will search in the log files created on that time and send their contents tot calamaris for specific user: <code> echo shell_exec("cat `ls `find ./logs -name access.log.* ` -l | grep May | awk '{print $9}'`| grep akadi_icho | /usr/bin/perl ./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -F html"); </code> but because the following command: <code> ls ./logs -l | grep May | awk '{print $9}' access.log.81 access.log.82 access.log.86 </code> it is not giving the path so the cat can't be executed (here i put for May just as example ), so i have used the command in this way combined with find command to get the path of the files: <code> ls `find ./logs -name access.log.*` -l | grep May | awk '{print $9}' ./logs/access.log.81 ./logs/access.log.82 ./logs/access.log.86 </code> now i want to send the contents of this file to calamaris for specific user such akadi_icho, but i don't know why cat is not working so , i tried the following way: <code> cat ./logs/`ls ./logs -l | grep May | awk '{print $9}'` | grep saro_der_avanesian output is : ages/letters/black/239.gif saro_der_avanesian FIRST_PARENT_MISS/proxy.aic.net image/gif 1178460942.330 848 10.2.0.181 TCP_MISS/200 459 GET http://www.google-analytics.com/__utm.gif? saro_der_avanesian FIRST_PARENT_MISS/proxy.aic.net image/gif cat: access.log.82: No such file or directory cat: access.log.86: No such file or directory </code> it is searching in the first file just , u can see that it didn't iterate for the second and third file , so what should i do . Quote Link to comment Share on other sites More sharing options...
trq Posted August 7, 2007 Share Posted August 7, 2007 ls -l $(find ./logs -name access.log.*) | grep May | awk '{print $9}' | xargs cat Quote Link to comment Share on other sites More sharing options...
akkad Posted August 9, 2007 Author Share Posted August 9, 2007 i have solved the problem thanx for ur help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.