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.
Related
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 2 years ago.
Improve this question
I get an exit behind a series of commands that returns me a huge list of servers.
Which start like this:
...linux.sapsmftexp01 ...linux.sappiftexp01 ...linux.sapbwftexp01
..linux.radiuswifiexp01 ..linux.gitlabexp01 ..linux.redisccexp01
I need to get only the name information, i.e .:
sapsmftexp01
sappiftexp01
sapbwftexp01
When I have tried to do it with cut -d
It deprives me of others, the same happens with awk, but someone has told me that I can do it from right to left, but I don't know how to do it.
Could someone help me please?
With sed:
sed -r 's/(linux)|(\.)//g;s/ /\n/gp' file
First remove any occurrences of "linux" or full stop and then replace spaces for new lines.
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 {}
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 5 years ago.
Improve this question
pretty new to linux scripting but getting the hang of it.
My questions is:
I have created a basic script to encrypt files, I basically want to restrict people running script.sh --help and if they do run anything such as this provide an error.
at the minute if I run the above command it simply executes the script as normal.
Thanks for any help.
If I got right your question:
#!/bin/bash
ARGS="$1"
if [ "$ARGS" == "--help" ]; then
echo "I EXIT"
exit
fi
# DO YOUR STUFF
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
I need to change some numbers in a rule, like 192.168.1.2 to 192.168.1.x, where x is a value between 3-254. So'll have multiple lines, one with the value 192.168.1.2, other with the value 192.168.1.3, and so on.
Well, I've no clue how to do that.
If someone know of a program or some way to do using a script in linux, please let me know.
Here's one way using GNU sed. Simply replace X with the value you wish to use.
sed 's/\(\([0-9]\{1,3\}\.\)\{3\}\)[0-9]\{1,3\}/\1X/g' file.txt
Test:
echo "192.168.1.4" | sed 's/\(\([0-9]\{1,3\}\.\)\{3\}\)[0-9]\{1,3\}/\1X/g'
Result:
192.168.1.X
Another option, using awk to avoid the hairy regex route (nothing wrong with regexes in general, but sometimes they can make your eyes bleed...):
awk -F. '{printf "%s.%s.%s.x\n",$1,$2,$3}'
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
So, to tail a log and watch it in real-time, one uses
tail -f <filename>
but what if you want to follow something else? Follow here is not really accurate I suppose, more like refresh the same set of data repeatedly.. is this possible?
I'm thinking of things like this: if you want to watch to see when a file moves from one folder to another, say as part of a function run through cron, you can use
ls -lR
repeatedly, but what I'm thinking of is something like the equivalent of:
ls -lR | tail -f
or
date | tail -f
to waste time watching the clock tick.
Is there anything like this, or is that just the limitation of the console.
Do you mean watch command?
watch -n 1 'date'
This way you can watch the time change for every second. Default is 2 seconds.