Skip to main content

All Questions

1 vote
3 answers
129 views

Passing directory names into a bash command individually [duplicate]

I have the following directory names: /aaa /bbb /ccc /ddd And I want to run the following command passing in the directory names with just ls: ls | composer show drupal/MY_DIRECTORY_NAME_HERE --...
Patoshi パトシ's user avatar
0 votes
2 answers
1k views

Error while reading File with Bash

I want to read a File in a bash script with the following code: #!/bin/bash file=$(sort "$1" | cut -f 1 -d "," | uniq -c | sed 's/^ *//g') while IFS= read -r line do echo &...
Leon's user avatar
  • 1
0 votes
2 answers
1k views

Nested read statement leads to infinite loop in bash

I'm trying to read a list of files from a command and ask the user for input for each file. I'm using one read to read the filenames, and another one to get user input, however this script seems to ...
Panayiotis's user avatar
-2 votes
1 answer
181 views

How to include interaction with the command in the same script?

I have written a script to run a specific program, my script contains many steps, some of these steps need my simple interaction by writing 0 then enter, How can I do that so that I don't need to ...
Mohamed Abdelaal's user avatar
6 votes
1 answer
8k views

How to abort if ssh control socket already exists?

I'm using the following line in my scripts: ssh -f -N -M -S <control socket> <host> This means the initial connection just stays in the background and I can use it for subsequent calls to ...
finefoot's user avatar
  • 3,504
12 votes
2 answers
13k views

How can I do an if conditional for a failure of a bash command?

I'd like to have a very simple condition that will only execute if the command fails. In this example it's a conditional based on the SUCCESS of the command. if command ; then echo "Command ...
Chris Stryczynski's user avatar
2 votes
3 answers
6k views

Progress bar to display progress based on number of files found/completed in for loop?

Is there a progress bar that can show visually completed progress based on the number of detected files found and completed in a for loop like the one below? mkdir -p hflip; for i in *.mp4; do ffmpeg ...
Anonymous's user avatar
  • 533
-1 votes
1 answer
50 views

Why is this bash script read line code giving me errors? [closed]

Why is this bash script read line code giving me errors? read -p "Does this require cropping? (y/n)? " answer case ${answer:0:1} in y|Y ) mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:...
Anonymous's user avatar
  • 533
-1 votes
1 answer
93 views

how to add additional command-line usage scenarios to script?

how can one make this script work with both input usage scenarios below? #1 ./script.sh #2 ./script.sh input.file contents of script.sh for i in *.mp4; do ffmpeg -i "$i" "${i%.*}.mp4 scenario ...
Anonymous's user avatar
  • 533
3 votes
2 answers
8k views

How to include custom command options in a bash script with $1 and $2?

I have a script myscript.sh #!/bin/sh echo $1 $2 which is used something like ... ./myscript.sh foo bar which gives me an output of ... foo bar but how can i make this script include custom ...
Anonymous's user avatar
  • 533
0 votes
2 answers
218 views

Concatenate the Content of Files from Various Directories with a Blank Line in Between

I have the file dir1.txt that contains the names of the following directories: 2 3 4 Directory 2 contains files 2_1.txt and 2_2.txt Directory 3 contains files 3_1.txt and 3_2.txt Directory 4 contains ...
soti84's user avatar
  • 5
2 votes
1 answer
615 views

How to modify these bash functions into one?

Normally these would go in one's .bashrc file to be used as a stopwatch, but they are sort of inconvienent to use and recall with the several different commands for the different units of time. ...
Anonymous's user avatar
  • 533
0 votes
2 answers
939 views

CLI run multiple commands and close terminal

I want to run the following commands and close the terminal: mysqldump -udatabase -pdatabase database > db.sql && zip db.sql.zip db.sql && rm db.sql && mv db.sql.zip /var/...
GoodGuy's user avatar
0 votes
1 answer
461 views

Command Line Options for a script

$ cat test15.sh #!/bin/bash # extracting command line options as parameters # echo while [ -n "$1" ] do case "$1" in -a) echo "Found the -a option" ;; -b) echo "Found the ...
Miloš Stojanović's user avatar
3 votes
2 answers
11k views

Bash: Timer in while loop

I have a while loop in my script which waits for the connection get online and then continues. #!/bin/sh while ! ping -c1 $1 &>/dev/null do echo "Ping Fail - `date`" done echo "Host ...
Vladimir P's user avatar

15 30 50 per page