Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I'm learning some bash shell scripting and I found a code on the internet:
PHP Code:
find . -exec du -cbsh '{}' +
the "'{}' +" is very weird to me. I dont think i can google it because it is special character. Please help me
tks for all the reply below. I was understand it but I have some problem now:
Quote:
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
but it will search some thing in /proc folder and have some problem like that
Quote:
find: `/proc/2046/task/2046/fd/5': No such file or directory
find: `/proc/2046/task/2046/fdinfo/5': No such file or directory
find: `/proc/2046/fd/5': No such file or directory
find: `/proc/2046/fdinfo/5': No such file or directory
3132 total
how I can deny this. I just want to get the total line
For understanding, you can devide this cmd in two parts, as:
Code:
find . -exec du -cbsh '{}' +
The part marked in red is searching for files inside current directory and keeps it in {}, which works like a container. Then in second part (marked in green) it executes some command on what first part has searched.
So it actually executes du -cbsh on files resulted from find . part.
Code:
du -cbsh file1
du -cbsh file2
du -cbsh file3 ... and so on
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
but it will search some thing in /proc folder and have some problem like that
Quote:
find: `/proc/2046/task/2046/fd/5': No such file or directory
find: `/proc/2046/task/2046/fdinfo/5': No such file or directory
find: `/proc/2046/fd/5': No such file or directory
find: `/proc/2046/fdinfo/5': No such file or directory
3132 total
how I can deny this. I just want to get the total line
@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
You can also run into permission problems, see shivaa's post for a solution for that.
@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
You can also run into permission problems, see shivaa's post for a solution for that.
tks for u and shivaa reply.
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
can u tell me what is 2 is . I'm such a noob
ah, I remember something I was read is it output code ?
IS 1 is standard input 2 is standard output ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.