I am trying to create a zsh script to test my project. The teacher supplied us with some input files and expected output files. I need to diff the output files from myExecutable with the expected output files. Question: Does $iF contain a string in the following code or some kind of bash reference to the file…
Tag: shell
Make a variable containing all digits from the stdout of the command run directly before it
I am trying to make a bash shell script that launches some jobs on a queuing system. After a job is launched, the launch command prints the job-id to the stdout, which I would like to ‘trap’ and then use in the next command. The job-id digits are the only digits in the stdout message. and then I w…
Unable to get the accurate value of shell variable set inside a pipe
I am trying to set a variable, based on the execution result of a MySQL statement like this: As you can see, due to pipe I am unable to get the value of the variable outside the loop (as the variable inside pipe, is basically set forking a different process) Is there any way i can extract the actual value
“Name or service not knownname” using SSH from script [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 7 y…
bash script – executing find command gives no output
I’m a total noob at bash so this is most likely a syntax error, but I could not find anything that worked for my syntax in my searches. From terminal, running find . -name “*g*” results in However, running this bash script called grepdir.sh from terminal as grepdir.sh . “*g*” res…
How to add more than 1 number in a loop in Bash script?
So I have this loop: I want to know how I can add 10 every time the loop repeats instead of adding 1. So I want the loop to look something like this: 110 120 130 140 and keep going until it reaches the limit or stopped! Thanks Answer Simply change ++ to += 10
“less” consumes lots of RAM for a piped output on gzipped file, why?
Excuse me for useless cat and echo upfront, but while running less on a ~2GB .gz file I’m seeing ~25GB of RAM getting consumed (despite the output being piped into awk and consumed there): I expected above to complete without any need for RAM, but to my surprise here is how it looked like ~2.5h later (b…
concatenate ordered files using cat on Linux
I have files from 1 to n, which look like the following: Each file contains only one line. Now I want to concatenate them in the order from 1 to n. I tried cat sim.o500.* > out.dat. Sadly this does not work if e.g. n is larger than 9, because this concatenates then sim.o500.1 followed by sim.o500.10and not…
Merge multiple files preserving the original sequence in unix
I have multiple (more than 100) text files in the directory such as The contents of the file are name of some variables like files_1_100.txt contains some variables names between 1 to 100 Similarly files_201_300.txt contains some variables between 101 to 200 and files_1001_1100.txt as I can merge them using t…
Make is unable to find the functions
I am trying to compile a C program, while linking the APR library. I am getting the following error message: cc -g -Wall -pthread -I/usr/local/apr/include/apr-1 -I/usr/local/apr/include/apr-util-1 -L/usr/local/apr/lib -L .aprutil-1 -L .apr-1 devpkg.c bstrlib.o db.o shell.o commands.o -o devpkg /tmp/cczC53x5.o…