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 …
Tag: bash
Linux – Do a command repeatedly for a certain length of time
I know what the command watch -n does. I would like to do something like the following: Essentially I want to repeat a command every 5 seconds, then stop after 30 minutes has passed. I’m missing the stop 30 minutes part. What command should I use to achieve this? Thanks. Answer Use timeout:
How to edit a particular line and replace text via sed in linux (cent os)
Width : 1 280 pixels Height : 720 pixels I’m working on a bash script and need to filter video on the bases of resolution. Like If Width is greater than equal to 1280 then HD else Non HD I’m using mediainfo to make and save info in txt file. output of this is 1 280 this is because of
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…
Match Anything In Between Strings For Linux Grep Command
I have read the post grep all characters including newline but I not working with XML so it’s a bit different with my Linux command. I have the following data: Using this command cat file.txt | grep -o ‘<tag.*tag>|^–.*’ I get: However, I want the output to be: How can I match any…
Check if any file in a directory contains words in a constant file
i have a directory with n textfiles. Now, i want to check, if any of these files contains one (or more) words of a constant file. These files are all dictionarys with a different amount of words. The constant file is a password list, where i want to check these words. The amount of correct hits should be save…
Error handling of user information in Unix
I need to do some error handling in the beginning of a script. If a user is not a member of a specific group then the script needs to exit. Answer or shorter:
How to exit from shell script if any of the command in SSH returns non-zero value
I have a shell script with below ssh command to perform few actions, Directory $remoteLocation/yyy is not available and it will display the error as, ./test.sh: line 6: cd: /opt/test/yyy: No such file or directory and it is proceeding to the next line. My scenario is to exit from the shell script itself if an…
Unable to parse bash output using regex and collect a part of it
I am trying to parse out the recent load, from the output of this command – The first one after the load average: – I was using this, which worked – However, I realised that the value I am looking for may not always be the 10th variable. Hence I am trying to use regex here, but unfortunately…
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