Skip to content

Tag: bash

redirecting stdin to tempfile in script

I want to write a bash script that receives a list of files through a pipe, writes a tempfile and then starts a program (qiv – an image viewer) with this tempfile. Example: where piped_qiv would look something like this: I’m probably missing something very basic about bash scripting but I was not …

Are linux shell pipes pipelined?

Given a file input.txt if I do something like is the output from the first command continuously passed (as soon as it is generated) as input to the second command? Or does the pipe wait until the first command finishes to start running the second command? Answer Yes, they’re pipelined — each compo…

Why can’t bash recognize the existence of a socket file

On a Linux box I want to check if a specific socket file exists. I know the socket files exists, but my checks in bash don’t show that to me: Why oh why can’t bash see that the file exists? Answer http://www.tldp.org/LDP/abs/html/fto.html Use -S to test if its a socket. -f is for regular files. Se…

Jenkins shell string quotation replacement

I have a Jenkins job with an execute shell box. In the execute shell I use bash instead of dash (sh). In the execute shell I have strings which are supposed to be interpreted as they contain escape sequences (in this case the new line: n), so here is an example execute shell: My problem here is that the scrip…

Use awk to create file

I have a file that contain : Mr Q 01629699998 Ms Nhung 011287633 … I would like to use this awk ‘{print “BEGIN:VCARD”;print “Name:”$0;print “TELEPHONE:”$0;print “END:VCARD”}’ file to create this result BEGIN:VCARD Name: Mr Q TELEPHONE:016296999…

bash: daemonizing by forking process as a new child

I have a bash script which should daemonize itself after being run. My solution looks as follows: However, putting the whole script itself inside the function child does not seem the correct thing to do. Unfortunately exec & won’t fork-off the whole process into a backgrounded child. How can a achie…