Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatenate a string to the end of every output line in bash/csh

In bash command line, if I run "find . -name 'abc*' ", it prints out a list of filenames like

abc1
abc2
abc3

How can I pipe it with echo or other command, so that i get this output:

abc1   ok
abc2   ok
abc3   ok
like image 273
SkypeMeSM Avatar asked Feb 08 '11 15:02

SkypeMeSM


People also ask

How do I concatenate strings in bash?

The += Operator in Bash Bash is a widely used shell in Linux, and it supports the '+=' operator to concatenate two variables. As the example above shows, in Bash, we can easily use the += operator to concatenate string variables.


2 Answers

Simply:

$ find . -name 'abc*' | xargs -I {} echo {} OK
like image 174
Diego Torres Milano Avatar answered Oct 26 '22 10:10

Diego Torres Milano


You could use xargs:

find -iname "abc" | xargs -IREPL echo REPL ok
like image 42
crudcore Avatar answered Oct 26 '22 10:10

crudcore