Skip to content
Advertisement

Tag: shell

How to read a variable from file, modify and safe it to an other variale

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

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

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 (?)

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:

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

Advertisement