Skip to content

Tag: bash

Storing awk manipulation in variable

I have two text files in tab delimted format like following. file_1 file_2 these two file contents were stored into two different variables. Now I would like extract the lines which has “+” symbol in column 4 and store it in the variable and later print it. But it throws me error message: Here is …

Serial Numbers from a Storage Controller over SSH

Background I’m working on a bash script to pull serial numbers and part numbers from all the devices in a server rack, my goal is to be able to run a single script (inventory.sh) and walk away while it generates text files containing the information I need. I’m using bash for maximum compatibility…

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