Skip to main content

All Questions

0 votes
2 answers
205 views

Command-line tool enabling tagging and related tags functionality

Is there a command-line tool that enables to give a file more attributes than a name? For example, we have a file called ubuntu.pdf and we give it tags like command-line, shell, nautilus, ...
xralf's user avatar
  • 15k
0 votes
0 answers
36 views

How to properly format the command argument for sudo? [duplicate]

I have a command that is similar to this minimal example: $ sh -c 'echo "1=$1"' _ foo 1=foo $ When I want to run it through sudo, it stops working: $ sudo -i -u user -- sh -c 'echo "1=...
finefoot's user avatar
  • 3,504
0 votes
4 answers
837 views

Bash: convert 100,000+ characters to decimal format?

I'm looking for a quick and not-so CPU intensive solution to convert 100,000+ lines of text into decimal format. # random ascii string='QPWOEIRUTYALSKDJFHGZMXNCBV,./;[]75498053$#!@*&^%(*' convert ...
user427459's user avatar
1 vote
2 answers
702 views

Function to go forward one directory, if possible?

I use below code snippet (by pressing alt-h), to go backward one level of current directory. up-dir() { cd ".." zle reset-prompt } zle -N up-dir bindkey "^[h" up-dir I want similar ...
raring-coffee20'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
0 votes
1 answer
89 views

How can I display the largest common part of two files?

I know how to use comm, diff or grep to display every common line of two files. But how can I display only the largest common part, i. e. the most common lines in succession? (If there are equally ...
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
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