Hello all I have a text file (1.txt) that contains full paths to binaries which I need to execute a command (val_bin) for each path in the file.

1.txt Example:


Command Example: val_bin- Creates an html file for every record in 1.txt

val_bin -output <DESTINATION.html> -path </source/ed/dev/ed/ab/ed_len/comercial/bin/APP1.bin>

where -output should have the path where the html files will be created after each time the command ends ("DESTINATION"). where -output should specify name.bin.html (e.g. App1.bin.html)

where -path needs to be the entire path fed into the command

example output: (where /tmp is the destination of the html files)

> ll /tmp

Ive tried several different loop options but now am investigating pure awk.


No scripting required.

xargs -I NAME val_bin -output /tmp/$(basename NAME).html -path NAME < 1.txt
| improve this answer | |

I'm guessing you want this:

while IFS= read -r bin; do
    if [[ ! -f "$bin" ]]; then
        printf "No such file: %s\n" "$bin"
        output="$dest_dir/$(basename "$bin").html"
        val_bin -output "$output" -path "$bin"
done < 1.txt
| improve this answer | |

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.