Shell scripts questions

O

OlgaD

Guest
Hi Professionals,
I have some shell scripts problem here,could you please check my shell scripts whichhas been attached.

I will be appreciated if you can help to reply me about this questions:
question A:why all variables followed by the backslash,it will be explained by Linux literally ;
question B:what is that mean" rm {} ",which has been stressed;
 

Attachments

  • logrotate.sh.txt
    2.3 KB · Views: 898


A.) I'm really not sure :) At first, it looks like a here script: http://linuxcommand.org/lc3_wss0030.php based on the 'EOF' at the end, but there is no previous command where the script would be sent to. Although the backslashes would make more sense if it was. The backslash will make the shell interpret the next character literally (looks like you already know this...) as far as why they are doing this I'm not sure unless they are sending the commands to another program rather than directly running it at the shell.

B.) rm {} is an argument to '-exec' in the find command. That line is saying, for any matches 'find' finds, it will execute 'rm' on that file (remove the file). Very helpful flag when trying to do something to multiple files:

For example:
Code:
find . -name "L*" -exec file {} \;
will find any files beginning with an uppercase "L" in the current dir and execute the 'file' command on each.
 
A.) I'm really not sure :) At first, it looks like a here script: based on the 'EOF' at the end, but there is no previous command where the script would be sent to. Although the backslashes would make more sense if it was. The backslash will make the shell interpret the next character literally (looks like you already know this...) as far as why they are doing this I'm not sure unless they are sending the commands to another program rather than directly running it at the shell.

B.) rm {} is an argument to '-exec' in the find command. That line is saying, for any matches 'find' finds, it will execute 'rm' on that file (remove the file). Very helpful flag when trying to do something to multiple files:

For example:
Code:
find . -name "L*" -exec file {} \;
will find any files beginning with an uppercase "L" in the current dir and execute the 'file' command on each.
thanks very much
 

Members online


Top