this post was submitted on 19 Sep 2026
29 points (100.0% liked)

Linux

67706 readers
276 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS
 

Edit: Thank you all for your quick responses! No downtime at all with this project! :D More specifically, I followed the advice to put command line parameters in the script. By slapping a $1 anywhere I want the filename to be expanded/accepted in the script, I was able to do

./command_ffmpeg_SYNCAUD  birthday_0  

I am digitizing my dad's video and audio tapes, for which I - after painstakingly scouring the documentation of ffmpeg, as one should - finally have found the encoding options that I'm happy with. :D

But instead of retyping the PhD dissertation that are the ffmpeg commands that I use a bazillion times, I have simply started to do command substitution with for instance

$(cat command_ffmpeg_COPYCODEC)  

or

$(cat command_ffmpeg_H264)  

and the likes. This, however, still requires me to vim the correct filenames into these concatenated commands every time I work on a new project, so I thought, "Why not just set a variable, like I use to do with visudo as in

EDITOR=/bin/vim visudo  

So, wanting to do a little ffmpeg magic to delay the audio stream of a file, I tried

FILENAME='birthday_0' $(cat command_ffmpeg_SYNCAUD)  

but bash said, "no, who do you think you are?" After doing a wc on FILENAME, I noticed that there is an invisible trailing something after the filename - possibly some whitespace char - since it thinks that I mean to use an option "-synced.mkv".

KiHVde8Vymkdsyn.jpg

How would you go about writing the now bash script (it simply wouldn't expand the variable through command substitution...) so that the trailing whatever is deleted, if that is indeed the case? I have tried slapping " ", ' ', ( ), { } in all conceivable configurations, but I'm simply to inexperienced. xD

Please advise! 🛠️

you are viewing a single comment's thread
view the rest of the comments
[–] talkingpumpkin@lemmy.world 4 points 4 days ago (1 children)
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"
[–] akunohana@piefed.blahaj.zone 3 points 4 days ago

Thanks! "Solving" it with bash does seem to be the easiest way forward. I'll fiddle around with it some! :D