0

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:

/source/ed/dev/ed/ab/ed_len/comercial/bin/APP1.bin 
/source/ed/dev/ed/ab/ed_lap/comercial/bin/APP2.bin 
/source/ed/dev/ed/ab/ky_len/Industrial/bin/APP3.bin
...

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

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
/tmp/APP1.bin.html
/tmp/APP2.bin.html
/tmp/APP3.bin.html
...

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

2

No scripting required.

xargs -I NAME val_bin -output /tmp/$(basename NAME).html -path NAME < 1.txt
0

I'm guessing you want this:

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

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.