have setup a master / local server combination using OpenSSH. My local server depends upon master server for a remote sourcing. The remote sourcing should set a large number of variables locally in a bash shell script. The code is:
user@slave $ source ssh user@master "/service/dyn.master.setenv.sh --mode=slave"
The var is not setting and I am getting various errors. How can I do a remote “source” of a bash script file (from master.example.com) and set a shell variable locally at slave.example.com?
work for a small ISP (Internet Service Provider) and we are using Linux and Unix-like operating system with bash shell. I want to write a shell script to parse the csv file line by line. Then line must be parse again field by field. The sample input file is as follows:
I need to extract each of these example.com,username,groupname,homedir,md5password,permission,secondarygroup fields and passed to the different system utilities. How do I write a shell script to automate this task and use the bash shell to parse a text file?
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 writing a shell script for automation purpose. The output the path of the current working directory is stored in $PWD or it can be obtained using the pwd command. How do I find out find out 3rd field separated by the forward slash (/) delimiter using $PWD under Unix like operating systems?
How do I set or create variables within my shell script or at command line under Linux and 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 assign printf command result to a shell variable under Unix like operating systems?