I need a tutorial/explanation for this script
Hi, I'm learning some bash shell scripting and I found a code on the internet:
PHP Code:
tks for all the reply below. I was understand it but I have some problem now: Quote:
|
It is part of the -exec syntax. It runs a single instance of the du command on the result of the search (multiple files). More details here: http://www.gnu.org/software/findutil...Multiple-Files
|
Once check this out here.
For understanding, you can devide this cmd in two parts, as: Code:
find . -exec du -cbsh '{}' + So it actually executes du -cbsh on files resulted from find . part. Code:
du -cbsh file1 |
Quote:
This Code:
find . -exec du -cbsh '{}' \; Code:
du -cbsh file1 Code:
find . -exec du -cbsh '{}' + Code:
du -cbsh file1 file2 file3 |
tks for all your help it is very useful
|
Sorry to tag it unsolved, but I have some problem with this code, I dont want to create many topic because I'm a noob :(
I just want to get the total line so I wrote this code Code:
find / -user u1 -type f -exec du -cbh '{}' + | tail -n 1 Quote:
|
These are pid file inside /proc corresponding to various process, which may have completed.
Also run this find command with root privileges, not a normal user, because you're seaching in root's home directory. Code:
~$ su - root |
@gbao256: Those message are generated by the find command.
Your find command also searches the /proc directory, which can be highly dynamic. The mentioned No such file or directory are files that have gone already. To suppress them use this: Code:
find / -user u1 -type f -exec du -cbh '{}' + 2>/dev/null | tail -n 1 |
Quote:
Your code work. I was think about /dev/null but my code dont work Code:
find / -user u1 -type f -exec du -cbh '{}' + >/dev/null | tail -n 1 ah, I remember something I was read is it output code ? IS 1 is standard input 2 is standard output ? |
1 (or "nothing") represents stdout en 2 stderr.
stdout outputs normal informations and stderr outputs errors. Have a look here for the whole story: Standard streams Bash related link: 3. All about redirection |
All times are GMT -5. The time now is 02:29 PM. |