2026-09-19 10:40 UTC
Replies (6)
-
@p_consti@lemmy.world 2026-09-19 10:51
Why are you not simply writing a script with an argument? Why this cat indirection with environment variables?
-
@thingsiplay@lemmy.ml 2026-09-19 10:57
First, did you look if the filename itself contains a trailing whitespace? I had this issue a few times myself, thinking the script is broken, but in fact the file on the filesystem had a space. That is annoying. If your variable has an additional space and you want to remove it, then I think its better to find out where this space comes from (if its not the file itself), and solve the issue there. Because if you get an unexpected space, then this could be a bug in your script somewhere. There are multiple ways to remove leading and trailing whitespaces with Bash. The best is not to call a command for this and rely on Bash substitution. This can get ugly, but luckily we can steal from Stack Overflow, :p (basically what we did before Ai): trim() { local var="$*" # remove leading whitespace characters var="${var#"${var%%[![:space:]]*}"}" # remove trailing whitespace characters var="${var%"${var##*[![:space:]]}"}" printf '%s' "$var" } stackoverflow.com/…/how-can-i-trim-whitespace-fro… (who got it from another source,
-
@merde@sh.itjust.works 2026-09-19 11:02
can’t you tr "endofthefilename " “endofthefilename”
-
@talkingpumpkin@lemmy.world 2026-09-19 11:02
FILENAME='birthday_0' $(cat command_ffmpeg_SYNCAUD) cat prints out a file without altering it’s contents. If it’s important to keep the commands in a separate file, you could use sed to find/replace, or use eval, or use some external template engine (lookup “bash expand variables in file”). What you probably want to do instead, I assume, is to replace the external files with regular bash variables: filename="some-file" command="ffmpg -i ${filename}.mpg -bla -blabla ${filename}.mkv" echo "$command"
-
@hexagonwin@lemmy.today 2026-09-19 18:25
i’m also a noob, but why not just do something like #!/bin/sh ffmpeg (options) $1 and run the script as ./script.sh filename.mkv?
-
@MonkderVierte@lemmy.zip 2026-09-23 09:25
I tend to do config loaders around commands like ffmpeg, magick, tidy. Just too much to research the switches each time you need them.