Using BASH FOR LOOP and PARALLEL [closed] - linux

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Just want to check if this is possible to automate in PRALLEL?. I have a bash script that reads a text file line per line and then takes the word of that line as a parameter then it will be processed by the bash script. For sample this would be the format of the text file
TEXT FILE
# cat test.txt
dog
cat
fish
rat
dove
Then line per line will be executed by a separate bash script via loop fashion like these
# for word in `cat test.txt`; do ./MY-BASH-SCRIPT.sh ${word}; done
Well this works fine however I it is executed one by one. May I ask for any suggestion on how can I possibly trigger the words in PRALLEL? I've gone and also read the GNU Parallel and gone some test however got no luck yet

this is now solved via parallel command:
cat test.txt | parallel ./MY-BASH-SCRIPT.sh {}

Related

The terminal shows me nothing gives unlimited space to write when i use grep function with file name in linux terminal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I used this command line to see what is inside grep command but it gives unlimited space to write. Why is this happening grep file.txt
It is finding instances of the literal text file.txt from standard input, aka your keyboard input.
If you want to search a file, use grep PATTERN -f FILE
Check out the grep man page for more details.
Plus, the entire point of grep is to search for a pattern, so you'll need that too.

Linux Internal Process for Cat and Grep [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm newbie to linux back round process, for example i have the below linux command, Maybe the question will duplicate here but i couldn't find answer so posting it.
cat test.txt | grep hello
how many back round process(s) will run? It would be great if insight on this.
There are two processes: cat and grep.
If you just launch the command line likt that, both processes are not background processes. (I guess you are asking background jobs?)
However, this example is not good, since you can just grep hello test.txt to save one process.
But if you just want to ask the number of processes, it's fine.

Script program inputs in bash ubuntu linux [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm in a course for C++ programming.
Our professor created a linux validation script against which our program output must match exactly.
It's running out of his own program and generates an output.txt file, then compares it against his output file, if it doesn't match it rejects the script.
The problem is, this program excepts probably 150-200 lines of input and if anything goes in wrong you have to start all over again. If you even enter an incorrect char, it must be restarted as the backspace registers as a character of its own.
How might I generate a bash script that would feed all of the input into the program automatically?
NOTE: We have to use his program as in: ~professor.name/submit asigname
You can create a text file:
answers.txt
answer1
answer2
...
answerN
and use that as stdin for the program:
./your_program < answers.txt
How might I generate a bash script that would feed all of the input into the program automatically?
Without any example code or input/output, it is hard to gauge what precisely is that you need.
Otherwise, for a generic tool to automate interactive console programs, I would suggest to take a look at the Expect.

How to print on stderr without using /dev/stderr [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How can a linux command script print warnings or error messages without using >/dev/stderr each time?
This should be simple but I don't get it.
Can you post a simple example?
To print to standard error, use a command that writes to standard output (like echo or printf) and redirect the output to file descriptor 2.
echo "This goes to standard output"
echo "This goes to standard error" >&2
This is the most common use of the file descriptor duplication operator, which makes the descriptor indicated by the preceding number (or 1 if omitted) a copy of the descriptor indicated by the following number.
Every unix process always has three open file descriptors when the process starts.
0 is stdin
1 is stdout
2 is stderr
http://man7.org/linux/man-pages/man3/stdout.3.html

How to write a program called biggest that takes any number of arguments [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So i am trying to write a program called biggest that takes any number of arguments. For all the
arguments that are files, it finds the file with the most words in it, and prints a line
such as:
File whatever has largest number of words (37)
assuming the file called "whatever" has 37 words, which is more (or the same) as
any other files in the current directory. If no arguments were valid files, then the
following line should be printed to stderr: biggest: no valid filenames were specified
The wc command seems like it would be useful, especially wc –w
please guide me with more help!!
Thanks
Put the following in a script and enjoy :
for i; do wc -w $i; done | sort -n | tail -1 | cut -d' ' -f2
PS: No one wants to help when you don't help yourself. For me it was timepass ;-)

Resources