People who code: we want your input. Take the Survey

Hot answers tagged

2

Use exec to change the current shell's file descriptors: exec 2>/dev/tty Use command -v to check whether a program is installed: if [ -t 0 ]; then if command -v zsh >/dev/null 2>&1; then zsh fi fi


2

@echo off set var="" if not exist version1.txt goto END for /F "delims=" %%a in ('findstr /C:%1 version.txt') do set var=%%a echo %var% for /f "tokens=1,2,3,4 delims=," %%a in ("%var%") do ( setlocal EnableDelayedExpansion set first=%%a set second=%%b set third=%%c set fourth=%%d echo %first% and %second% and %third% ...


1

General information The quoting in your code is very wrong. Important information: An unquoted variable undergoes word splitting and filename generation. Quotes that appear from variable expansion are not special to the shell that expanded the variable. There are two shells: the shell that interprets the script and the shell running in a container. Each ...


1

for … do … done & in your code runs in the background because of &. Shell code that runs in the background runs in a subshell. Such subshell inherits variables (even unexported ones) but it inherits them as copies, not references. So test_var1 in your for loop is a variable distinct from test_var1 in your main shell. The only connection is the ...


1

Use output seek: ffmpeg -i "in.mkv" -vf "subtitles=in.mkv" -ss 0:23:10.5 -to 0:24:40 -c:v libx264 -c:a aac "out.mp4" or Trim subs first. ffmpeg -i in.mkv -map 0:s:0 -ss 0:23:10.5 -to 0:24:40 subs.ass and then ffmpeg -ss 0:23:10.5 -to 0:24:40 -i "in.mkv" -vf "subtitles=subs.ass" -c:v libx264 -c:a aac "...


1

umask generally comes into picture when any new file or new directory is created with a specific user. if a file has 666 permissions, it grants read and write permission to everyone. Similarly a directory with 777 permissions, grants read, write, and execute permission to everyone. umask 000 --> provides 666 permission to all the newly created files , and ...


1

It is well known that Unix, Linux, and other Unix-like systems use a single character to represent the end of a line of text (EOL).  This character is called Newline and is often represented as \n.  This is somewhat confusing, as most software terminals (e.g., xterm) and hardware teletypes require two control characters to advance to a new line: a Carriage ...


1

You can't. In the context of terminals, Ctrl+I is Tab. Let me explain. The Control key was invented so terminal users could input "control characters" that their terminal keyboard might not have a dedicated key for. Control characters are all the ASCII characters with values below dec 32 (0x20). Holding down the Control key while you press another ...


1

In PowerShell, you can achieve your syntax like this: "C:\Playlist.m3u" | %{notepad.exe $_} "C:\Playlist.m3u" | %{&"C:\Program Files\VideoLAN\VLC\VLC.exe" $_} It pipes the path to the invocation of the executable and adds it as an argument.


1

So Windows applies a concept called "File Type Associations" or "Default Programs" or "Default Apps" depending on your version, but they all do the same thing. they associate a files extension (eg m3u) with an application and optionally a set of arguments. The goal of a file type association, is to allow you to simply open a ...


1

I believe using the subprocess library will help in what you want to do. Here's an example (according to the question): import subprocess import shlex command = shlex.split("<your command to run the script>") process = subprocess.Popen(command) try: outs, errs = process.communicate(timeout=5) except TimeoutExpired: process.kill() ...


1

Approach 1 - Read from file You can save the password in a read-only file for the user and pass the contents to the sudo command. This will avoid password being stored in shell history # Save the password in the hidden file echo "password" > ~/.password # Update the permissions to allow only the user to read it chmod 400 ~/.password # Pass ...


1

notify() { emulate -L zsh # Reset shell options inside this function. # Fetch the last command with elapsed time from history: local -a stats=( "${=$(fc -Dl -1)}" ) # = splits the string into an array of words. # The elapsed time is the second word in the array. # Convert the elapsed minutes (and potentially hours) to seconds: ...


Only top voted, non community-wiki answers of a minimum length are eligible