Jump to content

[SOLVED] multiple output redirection in linux


Recommended Posts

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.

 

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 .

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.