I need to grep a file called daily_fails_count.csv but only find the number of failures. Inside that file is this, on a shorter scale: It’s format is “month,day,hours,failures.” It goes through all months. The last value is the number of failures found at that time. I know here it all says 0…
Tag: bash
Storing only part of output into shell variable
hi i am using a bash script. here i execute this code. This will return a output as Now i know how to store this entire output into a single variable and print it But i am not able to figure out how to store partial information into variable. Like if i want to store only TEST1 into the variable,
Bash – Remove XML nodes if the attribute value of a child node does not equal a specific value?
I have RSS feed, like this: I want remove all nodes (/feed/entry) where link href != http://myhomesite.com. How do I remove XML node where value start at specified symbols using Bash? Answer Bash features by themselves are not very well suited parsing XML. This renowned Bash FAQ states the following: Do not a…
how to avoid enviroment variable from resetting in WSL terminal after restart?
environment variable set (in zsh shell) in WSL disappears after restarting the terminal. I have used to set environment variable. how should I avoid env variable from resetting after restart. Answer I added environment variable in .zshrc file after reading comment of @Biswapriyo. like this- export variable_na…
Concatenating hardcoded directory and user-created text file adds root-level paths when it shouldn’t
I have written a script to allow a restricted user access to deleting files on a production webserver. However, to prevent fat-fingering issues leading to accidental filesystem deletion/problems, I have hard coded the base directory in a variable… But the final result is not properly creating the desire…
How to get 2 strings between certain characters in bash
String: I want to grab everything before the first instance of | and everything between External_SOC and ;PCRF. And store them as 2 different variables if possible. This gives me the following: 40125512ALPHA3 Answer EDIT: As per OP it needs to be done in a single line creation 2 of variables if this is the ca…
Getting only hexa decimal byte values from the disassembly of a compiled library
I have used objdump to disassemble all the functions in a compiled library file and written the output to a text file. In the text file the output of function called clear_bit is as follows. The output of an another function set_bit is as follows-: Similar to the above two functions, this output.txt contains …
Linux bash ‘[: -ge: unary operator expected’ error
I tried this code and it gives many errors that could anyone help me to fix this problem please. Answer The source of the problem reported in the question is an empty decvalue as syme has already stated. Considering the purpose of the script, it seems you attempted to write a recursive function. For this reas…
Alternative to cron that retains environment variables
I have been trying to set up a cron job to run a bash script every 30 minutes on a Linux-based compute cluster. The problem is that some functions normally available in my shell are not available to the cron job, causing it to crash. I import all my environment variables (including the ~/.bashrc) but no luck,…
Remove part of file name in multiple sub directories
The main folder “Main” contains multiple subfolders (6900,159, 9997, …) and each subfolder contains 8 items (4 files (6900Log.final.out, 6900Log.out, 6900Log.progress.out, 6900SJ.out.tab), 3 folders (6900_STARgenome, 6900_STARpass1, 6900_STARtmp), and one compressed file (6900Aligned.sortedB…