Skip to content

Tag: sh

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…

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 (wher…

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

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 fil…