Skip to content
Advertisement

Tag: sh

Unable to pass filename with space through variable to SCP command

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

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

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

Advertisement