Comment on Some people just can't place themselves
joyjoy@lemmy.world 1 year agoIs your issue about just syntax?
for part in $text; do echo "xX$partXx" 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$lineXx" done <<< "$text"
ArcaneSlime@lemmy.dbzer0.com 1 year ago
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.)joyjoy@lemmy.world 1 year ago
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.
ArcaneSlime@lemmy.dbzer0.com 1 year ago
Thanks for the info, it definitely helped!