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 1 year ago.
Improve this question
What is the way to know the IP address of a website such as Www.google.com by bash script?
ping -c1 www.google.com | grep PING | cut -d"(" -f2 | cut -d ")" -f1
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
Hel lo I have a df file such as
col1;col2;col3;col4
A;B;C;D
E;F;G;H
I;J;K;L
and I would like to grep I and only display the col1 and col2
and get
I;J then
because from now I only know how to do :
grep 'I' df.csv
I;J;K;L
Try this:
grep 'I' df.csv | cut -d';' -f1-2
The cut command will treat each input line as a list of fields separated by ; (-d';'), and will select only the first two fields (-f1-2) for output.
Sample session:
$ cat df.csv
col1;col2;col3;col4
A;B;C;D
E;F;G;H
I;J;K;L
$ grep 'I' df.csv | cut -d';' -f1-2
I;J
$
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
Exactly what the title says: what is the bash command for printing out the longest word in a text file that appears at least 10 times.
Try this Denis:
tr -s " " "\n" < file | while read -r l; do echo "${#l} $l"; done | sort -n | awk '$1 >= 10 ' | awk '{print $2}' | tail -n1
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
ps -ef | grep --color "ilir1477" | awk '{print $NF}'
Please explain to me.
Is this what you are after?
$ ps -u ilir1477 -o args=
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
Is it possible to get the server UPTIME from mentioning PORT number or Process ID in UNIX command? Please help! Thanks!
From port - I don't think so.
From process ID :
ps -eo pid,etime | grep " 1 " | grep -v grep | awk '{print $2}'
Example:
root#localhost:~[0]$ ps -eo pid,etime | grep " 1 " | grep -v grep | awk '{print $2}'
01:16:10
root#localhost:~[0]$
But you can use uptime command.
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
For some mysterious reason, whenever I run grep from a "standalone" shell script as opposed to a simple function, the coloring of the output is not preserved.
Why is this happening and how can I prevent it?
This is best illustrated with an example:
You should try in your script :
grep --color
But please, no need to
echo `ls` | grep ".txt"
just
ls -1 | grep --color ".txt"
or
printf '%s\n' | grep --color ".txt"
See http://porkmail.org/era/unix/award.html
EDIT
To change the defautl colors of grep, see man grep and search GREP_COLORS