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
Tag: shell
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
Unable to use SED command [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question i want to call a shell scripts which has sed command in it to format the xyz.csv generated by this shell. SED gets unrecognised in
How to get python version in shell script?
Objective: to get python version in shell script Observation: Code: Expected: Actual: Please help me getting python version in shell script. Answer the –version writes to stderr, so:
How SSH Environment Variables works with shell script file?
If I run the command bellow and my install.sh has the following section: cat install.sh | ssh $PRD_USER@$PRD_HOST The $PRD_S3_ACCESS_KEY is going to be resolved from my host or the environment variables from the remote server? Answer Assuming you have gettext installed (which contains envsubst), you can do
How to get unix style prompt in windows (batch)
I am trying to make dos shell which displayes a unix/linux promt. The code is: I want it to display directory name like in unix/linux but it displays a ~. What is wrong in my code? Can you please help me improve it? Answer Probably not quite on the ball with the prompts specific situational substring modification, but the Method
How to run remote script on multiple host simultaneously
I have a great amount of Linux servers to maintain. Frequently I need to run a script (script.sh) on all of them to get the health status, this script usually takes about 30-40 seconds to give an output. To facilitate maintenance tasks, I’m writing a shell script that uses SSH to loop through all remote hosts, run script.sh, collect output
GREP to search for second column in a text file
I need to GREP second column (path name) from the text file. I have a text file which has a md5checksum filepath size . Such as: the above is the text file, I used grep -Eo ‘[/]’ file.txt but it prints only / , but i want the output like this: Lastly I have to use GREP. Answer If you
Shell Script to extract only file name
I have file format like this (publishfile.txt) I just want to extract the name OMEGA****, sample, sample(1) How can I do that I have used basename in my code but it doesn’t work in for loop. Here is my sample code But this code also doesn’t wor when used outside for loop Answer This simply says that the delimiter is
Copy a folder contents and save the file with diff name Unix
I have a bunch of .txt files in a directory. I m looking for a command to copy all .txt files and save it with <filename>_2.txt. Eg: abc.txt -> abc_2.txt (After copy) Thanks in tons in advance Answer EDIT: As per OP’s extension request adding following code now. Try following. Above will print cp commands, if you are ok with