Warning: Some posts on this platform may contain adult material intended for mature audiences only. Viewer discretion is advised. By clicking ‘Continue’, you confirm that you are 18 years or older and consent to viewing explicit content.
I think my issue may be more than just syntax, I really am inexperienced lol, all just learning as I go (unix philosophy and all lol, I kid).
The for loop I stole from the internet for use with ffmpeg is
for i in *$input; do ffmpeg -i "$i""${i%.*}$output"; done
So I know what it does, it takes the input (read by the script earlier) filetype and changes it to the output filetype also read earlier for all of the files of $input type in the current directory, and I know how I got input and output as variables, and I know the ffmpeg -i foo -o bar command, but I get completely lost on "$i""${i%.*}$output";. I don’t really understand when to use what brackets or where I need semicolons and why, though I do understand that $ calls a variable and * is an operator to designate “all,” I’m not entirely sure what this part of my script is doing (as this loop is the part I copied from stackexchange, and only half understood it “but it worked so fuck it” lol.)
Is your issue about just syntax?
for part in $text; do echo "xX${part}Xx" done
In bash, this loops over each word in a variable. If you want each line, you’ll need to use a while read loop instead.
while read -r line; do echo "xX${line}Xx" done <<< "$text"
I think my issue may be more than just syntax, I really am inexperienced lol, all just learning as I go (unix philosophy and all lol, I kid).
The for loop I stole from the internet for use with ffmpeg is
for i in *$input; do ffmpeg -i "$i" "${i%.*}$output"; done
So I know what it does, it takes the input (read by the script earlier) filetype and changes it to the output filetype also read earlier for all of the files of $input type in the current directory, and I know how I got input and output as variables, and I know the ffmpeg -i foo -o bar command, but I get completely lost on
"$i" "${i%.*}$output";
. I don’t really understand when to use what brackets or where I need semicolons and why, though I do understand that $ calls a variable and * is an operator to designate “all,” I’m not entirely sure what this part of my script is doing (as this loop is the part I copied from stackexchange, and only half understood it “but it worked so fuck it” lol.)The ${} syntax manipulates a variable. In this instance, I believe % removes a suffix. # is for a prefix. I can never remember which is which.
Semicolons just separate statements. You can replace them with a new line to get the same effect.
Thanks for the info, it definitely helped!