I'm looking for a script that read all my files and find those which have int tube[2] written at the beginning of any line, I should use

sed -e 's/Ancien/Nouveau/g' nomFichierEntrée > nomFichierSortie

But how to loop on my files?

for int i in ls do
    sed '^int tube[2]'

or am I missing something?

And how to use it?

grep -l '^int tube\[2]' ./*

Would list the non-hidden files in the current directory that have at least one line that starts with int tube[2]. The [ needs to be escaped as it's a regexp operator.

In any case, parsing the output of ls is generally a bad idea.

for i in $( ls ); do

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.