pihug12
pihug12

Reputation: 317

'Exec' parameter with 'echo' and 'awk' filter

There's this line I want to use in a ksh script :

find . -type f -exec echo "{} $comment" | awk '{printf "%-30s %s", $1, $2}' \;

Without the awk, this line is working great :

find . -type f -exec echo "{} $comment" \;

When I added the awk to make columns, I had this error :

awk: fatal: cannot open file `;' for reading (No such file or directory)
find: missing argument to `-exec'

I don't find the good syntax. Do you, guys, have any idea ?
Thanks !

Upvotes: 1

Views: 1412

Answers (2)

potong
potong

Reputation: 58508

This might work for you:

 find . -type f -exec printf "%-30s %s\n" "{}" "$comment" \; 

Upvotes: 0

There a 2 things that I actually cannot understand.

  1. What is \; stand for?

  2. What is - for in printf "%-30s %s", $1, $2?

Anyway, try that.

$> find . -type f -exec echo "{} $comment" \; | awk '{printf "%30s %s\n", $1, $2}'

Upvotes: 1

Related Questions