I apologize beforehand for the jumbled mess that is the title but that’s the shortest way I could think to describe what I’m trying to do. I’m reading a file that has multiple lines of text that I’m looping through and I’m trying to use regex to get a substring from each line. These lines will start with the word
Tag: bash
Parse From Text File into String output
So I have a text file called employees.txt that looks like this… I’m trying to write a sed script that will read in the text file then output it in the format “< name > is a < gender >, and is < age > years old now.” I know I need to set the IFS=, but I’m stuck on
Find the closest match between two files in unix
As a beginner i’m looking for a solution in shell scripting, I have file1 with content as below lines: And file2 with filenames and their modified timestamp. I’m looking shell script solution where it can tell the closest match in timestamp in the between both files. Like timestamp_x and timestamp_y comes in between timestamp_1 and timestamp_2. Thanks Answer If your
Bash script how to display matched words in custom order
The following is the output of the command ads2 cls create However, I’m trying to extract the value of name and state for each node, save them in a variable and display them in the following order: Till now i, with the help of this so much powerful learning site, could extract the values of name and state by executing
Is there a way to remove results from find in linux?
I have a directory with backups. One backup file is created each day. I need to remove these files as they fill up disk space over time. I want to remove all files older than 5 days, BUT I need to keep a minimum of 5 files in the directory. This is in case the backup utility fails 5 days
Capturing output from a background subshell in bash?
I’m trying to run multiple subshells in a bash script and capture the stdout result to a variable. When I run the subshell in the background I would expect I can use wait to let the subshell complete and then use the variable the result is assigned to later in the program…. but it doesn’t seem to work. Simple example
Wait Until Previous Command Completes
I have written a bash script on my MacMini to execute anytime a file has completed downloading. After the file download is complete, the mac mounts my NAS, renames the file, and then copies the file from the mac to the NAS, deletes the file from the mac and then unmounts the NAS. My issue is, sometimes, the NAS takes
Redirect bash script output in editor without saving file
I have a script that outputs a few lines and I want to have it open in an editor on my system (nano, vim, whatever) to be ready to edit. However I don’t want to save it to a temporary file or variable but directly in the editor (I think I need to bring the out somehow into the editor’s
grep -r –include not works but –exclude works
In bash, What’s the problem? Answer You are using curly braces incorrectly. The correct syntax would look like (Notice also the addition of the missing file name argument . at the end.) You can see what’s going wrong by putting an echo in front and examining what the shell expands the braces to.
How to connect to SQLPLUS and run SQL script within ssh unix?
I have the following bash script: Now, I want to run te following sql script (which is on the other device I’m accessing): How is the best practice to run the script from that path? I’ve seen a suggestion to add “/usr/mikael/myfile.sql” to the end of the command, as : Is that really good? (I’m working on a prod environment