Skip to content

Tag: unix

Difference on bash and ash parentheses

I was trying to use a diff command for comparing directory listings which works fine in bash: However, on the ash (embedded device where no other shell is available) I get Is there any difference regarding reading input operator < or parentheses ( )? Answer Don’t confuse the angle bracket in <( … …

How can I fix the following sed command?

I am trying to append _out to anything that matches the regex shown in the follwing sed command. The _out should be before the [ (]. The command returns the lines correctly as I expect. Now the problem comes when I try the following command where I define regions to use in the replacement. So for example if I…

command blkid don’t show my partitions UUID

I’m using Ubuntu. command blkid or blk /dev/sda2 in LPIC-1 module 104.3 (mounting and unmounting). but these commands don’t show me the expected results. blkid is installed and also I can see man blkid !!! Could you guide me to fix this? Answer Run sudo blkid After that you will be able to get the…

How to abort if command fails in Unix shell?

I’m not very great with shell scripting and still couldn’t find a solution to this. I want to run a command gulp tslint and if it returns errors, abort the script. So far I tried gulp tslint || exit 1 with no success. I think it somehow is returning true, even though it has errors when i run it on

Validating file records shell script

I have a file with content as follows and want to validate the content as 1.I have entries of rec$NUM and this field should be repeated 7 times only. for example I have rec1.any_attribute this rec1 should come only 7 times in whole file. 2.I need validating script for this. If records for rec$NUM are less tha…

escape alarm() process timeout with nohup or setsid?

I have a monitoring application, Zabbix agent, that allows me to run arbitrary commands/scripts and grab the return value. The agent is configured with a timeout and any command that exceeds the timeout will be killed. For every command that is run, it first sets the timeout via alarm(timeout) and then forks …

How does netstat determine symbolic hostname?

I was trying to understand what the –numeric/-n flag of netstat does? Manual says the following about –numeric/-n –numeric , -n Show numerical addresses instead of trying to determine symbolic host, port or user names. Following is a line of output with “-n” option Following is t…

how to execute init scripts from the command line using ssh

Above mentioned code works fine and displays all the contents of the test directory folder but this code fails It does not start the mysql server, I have login in to server and use the same command to start the mysql server Can any one explain this behaviour ? what I am doing wrong bit puzzled 🙁 Answer Do som…

Can socket send fail cause a daemon program crash?

I have two applications running on Embedded Linux board. One runs as a daemon and other acts as an interface for it. They communicate with each other using Unix sockets. As to handle any abnormal termination of socket, I tried terminating the interface application [ctr+c]. But as a result, the daemon applicat…