I am trying to set the variable $file as “Unavailable Voucher’s Report_Apr-2017.txt”. It is getting set to the variable successfully. But I am getting an error when I use this variable in a SCP command inside my script. I have tried to replace the ‘ ‘(space) with ‘ ‘(escaping space), still no use. Error be like: Answer Try to double
Tag: sh
script to check script is running and start it, if it’s stopped
I have a script with this name : Run.sh I run this script with this command : I don’t like stop this script but this script Suddenly stops and need run again. I need a script to check it , if my run.sh stopped , run it again. this is run.sh codes: And i want run this script at boot
Tar search results in .sh file
I have to tar a list of files, without path, that is a result of a find via sh (for crontab use). In ubuntu’s shell each command works fine but in .sh not. I tried with : And also with But both failed. May someone help? Alternatives ? Additional scenario info: /myfolder/ contains: one1.log one2.log one3.log two1.log two2.log I want
Validate text file presents expected fields for each data set
If one has a document in this format: You could verify each field exists for each data point manually by scrolling through thousands of lines in a file, but that would be inefficient and time consuming. I have thought about splitting the file and comparing each section using diff, but again, that would be prone to issues if there is
How to turn off printing result of python “sh” library
I’m working on services with Python, when I try to get status of a service with Python sh library, It will return results in a variable like so: It works fine, but when I try to get status of supervisor service it will print all the results in the terminal and destroys my command outputs. So how to turn off
Bash/SH, Same command different output?
And the last one is correct. Why is that? and how to solve it? Answer Per POSIX, echo supports no options. Therefore, when echo -n is run with sh, it outputs literal -n instead of interpreting -n as the no-trailing-newline option: Note: Not all sh implementations behave this way; some, such as on Ubuntu (where dash acts as sh), do
If [ $? -ne 0 ]; not working?
I am trying to detect a running service and if not there, try to do something: The service is clearly there but still I am getting “Service not there.” I read about the exit code $? I think maybe the exit code in a series of commands might have effect on what we wanna test? So I am not sure
How to write a bash script which calls itself with python?
Can someone explain how this bash script works? The part I don’t understand is “””:”, what does this syntax mean in bash? test running result: Answer That’s clever! In Bash, the “””:” will be expanded into only :, which is the empty command (it doesn’t do anything). So, the next few lines will be executed, leading to exec. At that
Find out the shell which was used to run the process in linux?
I recently got stuck in a situation where I need to find out the name of the shell for a list of process (or for a single process, using pid). Is there a way we can find it out (preferably using ps and grep command). Answer Since you know that the processes have been started from a shell, you just
linux sed reads whole file when only editing first line
I am currently working with CSV files that can be 10’s of GB in size, and need to edit the headers dynamically depending on the use case. For this I am using: which has the desired effect of only editing the headers, but can take upwards of 10 seconds to complete. I imagine this is because the whole file is