What I want: There is a file /scripts/backup/config.cfg which contains variables. In my specific case the important ones are: Then there is a script /scripts/backup/performBackup.sh For a specific reason I want a part of the script do the following operations: read the value of the variable ROOTLOCATION add a (“/” and) timestamp (Date&Time) safe the new created value to BACKUPLOCATION
Tag: shell
Unix -Delete even bytes from a file
I want to find and delete all even bytes from a file given in command line. Is there any command for this situation? Answer I think this does what you want. It dumps the file as continuous plain hex, then reads two bytes, saving them for later and then two more bytes. Then it outputs the bytes it saved and
Declaring variables with indirect reference with a prefix
I have my parameters stored in a file and calling them with a prefix which i get it has input. now, i am getting the input and prefixing it and storing as a new variable and then pointing my new variable indirectly to my actual variable to use in my script. Is there a way to directly mention the indirect
grep a file to read a key:value
I have a file file.txt which has various key:value pairs. While reading a particular value from file, more than one lines are printed. Please help me in correcting my logic below. INPUT_FILE DESIRED_OUTPUT 1234_12345678_987 MY_CODE cat file.txt | grep -w 1234-A0 | cut -f2 -d ‘:’ OUTPUT 1234-A0;5678-B0;3456-C0 1234_12345678_987 Please let me know what’s wrong in the above command (?)
what’s the meaning of exit code of program with empty void main()?
I made a simple C program with empty main as given below and compiled it with gcc upon execution, it return exit code as 25, and if I add a printf statement,after including stdio.h, it returns exit code 5 what’s the meaning of 25 and 5 here and why it’s being returned by whatever code that is executed before or
Read lines from a file and tokenize each line to extract specific word in shell script
I wrote a shell script to read all lines from a file, tokenized each line to extract particular word. First line is read correct, but from the second line the expected word is not reading correctly. Looking forward for your suggestions. Contents of route.sh are Actual output Expected output Extra Note: My objective is to (network concept) Read all lines
Append date to a filename in linux
I want add the date next to a filename (“somefile.txt”). For example: somefile_DDMMYYYYHHMMSS.txt Maybe a script will do or some command in the terminal window. I’m using Linux. Thanks in advance. Answer Something like can do the work:
How can i display the first five lines that differ between 2 files, in a shell script?
I ve tried using 2 arrays to compare the 2 files, but i m a rookie and i don’t know how to do it: Answer Do not use backticks `. Use $(..) instead. So instead of if ( “$i” == “$j” ) do if [ “$i” != “$j” ]. vec_fis_1 and vec_fis_2 are not arrays – ${vec_fis_1[@]} is just same
Shell script: Using own IP adresss as variable
I have to write a shell script which initializes docker swarm. I need to pass the own IP address as argument: How can I do this dynamically? I know the ifconfig command, which allows me to see the IP, but I can not pass the whole thing as variable. It should look like this Answer The following command will return
top and grep output nothing when run from shell script
I am trying to create shell script that ssh into a remote server and run a script there and print the output in the local server but when I run the script in the local server it most of the time outputs nothing and rarely outputs data : and when I ssh in the local server to the remote server