I want to extract version string (1_4_5) from my-app-1_4_5.img and then convert into dot version (1.4.5) without filename. Version string will have three (1_4_5) or four (1_4_5_7) segments. Have this one liner working ls my-app-1_4_5.img | cut -d’-‘ -f 3 | cut -d’.’ -f 1 | tr _ . Would like to know if there is any better way rather
Tag: sh
How to run a file in variable
I want to run this command: ././pscan `cat ips` 22 but the script don’t run corectly and i want to run command e.g: ././pscan 1.1 22 ././pscan 2.2 22 ././pscan 3.3 22 ././pscan 4.4 22 ././pscan 5.5 22 the script pscan works perfectly when i type on single command ././pscan 1.1 22 and i want to run more than 5.5
Changing contents of a tsx file through shell script
I have a requirement to change the contents of config.tsx file that contains values like: I want to change this content using a shell script and save the file. Changed content can look like: How can I do this? Answer This should work: The -i option will edit the file in place. If you first want to try the command
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 (?)
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
How to run jar files sequentially from a shell script
I am trying to run two java application one after other in my docker container. In my dockerfile i have specified invoker.sh as the entry point. ENTRYPOINT [“sh”, “/opt/invoker.sh”] Then i use this script to run two jar files. but this does not work. It gives Error: Unable to access jarfile javaimpl-loader.jar and only the service.jar is executed. When i
Unable to get the absolute value of command output
So I wanted to make a simple script to keep checking the CPU temperature of my RasPi, which is stored in /sys/class/thermal/thermal_zone0/temp , and hence cat /sys/class/thermal/thermal_zone0/temp would give the temp, but like this : which essentially means 38.459 degree Celsius. I was unable to format the output to get 38.594 °C My code: The error I get: Thanks Answer
Shell : create and assign variables inside for loop
i ve this shell script ; it’s a loop which set in the variable “a” each time result : My Purpose is how to change “a” by a dynamic variable name which be $item_MYPREFIX (concatination :$item + _MYPREFIX ) So that my code would be generic , something like this : and i would be able to display each variable
Remove column matching 2 patterns with AWK
Multiple lists of Books with ISBN,TITLE,OBSERVATION and other with OBSERVATION,TITLE,ISBN, I want remove column OBSERVATION, print TITLE as 1st column and ISBN as 2nd as follow. Input: 123654 Cosmology Updated 35647 Medecine Revised 987456 Juriprudence Revised Updated Rhetorics 123456 Revised epistomolgy 654321 Ouput desired: Cosmolgy 123654 Medecine 35647 Rhetorics 123456 epistomolgy 654321 I tried this code found in SE and
Storing only part of output into shell variable
hi i am using a bash script. here i execute this code. This will return a output as Now i know how to store this entire output into a single variable and print it But i am not able to figure out how to store partial information into variable. Like if i want to store only TEST1 into the variable,