M
M
Maxic_unrelax2014-02-17 23:51:10
linux
Maxic_unrelax, 2014-02-17 23:51:10

Bash - for and find

Please tell me: (lab assignment)
2. Write a script using a for loop that displays the sizes and permissions for all files in a given directory and all its subdirectories (the directory name is specified by the user as the first command line argument).
How exactly to bind the for loop to the result from find ?
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
egor_nullptr, 2014-02-18
@Maxic_unrelax

#!/usr/bin/env bash
for file in `find $1 -type f`; do
    ls -ogh --time-style=+"" $file
done

V
Vlad Zhivotnev, 2014-02-18
@inkvizitor68sl

And why did you ask the question? to solve the problem for you from the university? Drive you in the neck from there.
This resource is not about solving other people's problems. This is a resource about questions and knowledge.

R
RPG, 2014-02-18
@RPG

for file in `find ...`; do echo $file; done
find and xargs are supplied in the same package, and -print0 ensures that file names are not affected in any way during transfer. Plus, I advise man find, the -exec option.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question