I often type the wrong command as follows under Linux bash shell:
rsync -av dir1 email@example.com:/path/to/dir1
cp -av file1*.txt file2*.txt /path/to/dest
I need to correct those command as follows:
rsync -av dir5 firstname.lastname@example.org:/path/to/dir1
cp -av delta1*.txt delta2*.txt /path/to/dest
How do I replace dir1 with dir5 or file with delta and repeat the last command under bash shell?
I‘m writing a bash wrapper script that will pass arguments to the command. I need to find out the last argument if I call the wrapper as follows:
./wrapper -a -b –longarg=foo thisfilename.txt
./wrapper -a -b thisfilename.txt
./wrapper -a –next=true thisfilename.txt
=> $@ is all of them.
=> $0 is script name.
=> $1 is first arg.
I want thisfilename.txt stored in a shell variable called $last. How do I find the last argument passed to a shell script written in bash or ksh under Unix like operating systems?
I‘m using the date +’%D_%T’ to store Unix system date and time in a shell variable called $_now:
I’d like to replace / and : with _. I’m aware of the following sed command:
> s/:/_/g’ <<<"$_now"
How do I specify two pattern within the same sed command to replace | and : with _ so that I can get output as 01_20_12_16_10_42?
How do I use the bash C style for loop under UNIX or Linux operating systems?
How do I run “foo” command 10 times (or n times) under Linux or UNIX like operating systems?
How do I auto Logout my shell user in Linux after certain minutes of inactivity?
I have a file of that looks as follows:
Each word and/or Linux is a different length. How do strip or remove the last character from each line using bash or ksh shell only?