Most Popular

1500 questions
144
votes
4 answers

How do I pass a list of files to grep

I am using find and getting a list of files I want to grep through. How do I pipe that list to grep?
Tegra Detra
  • 5,016
144
votes
3 answers

grep on a variable

Let's say I have a variable line="This is where we select from a table." now I want to grep how many times does select occur in the sentence. grep -ci "select" $line I tried that, but it did not work. I also tried grep -ci "select" "$line" It…
gkmohit
  • 3,309
144
votes
7 answers

Cause a script to execute after networking has started?

I am relatively new to systemd and am learning its architecture. Right now, I'm trying to figure out how to cause a custom shell script to run. This script needs to run after the networking layer has started up. I'm running Arch, using systemd as…
fdmillion
  • 2,828
144
votes
6 answers

Where do files go when the rm command is issued?

Recently I accidentally did rm on a set of files and it got me thinking where exactly these files end up? That is to say, when working with a GUI, deleted files go to the Trash. What's the equivalent for rm and is there a way of undoing an rm…
boehj
  • 2,630
143
votes
7 answers

Why is cd not a program?

I've always wondered why cd isn't a program, but never managed to find the answer. Anyone know why this is the case?
AkshaiShah
  • 3,629
143
votes
1 answer

Why eval the output of ssh-agent?

In order to run ssh-agent I have to use: eval $(ssh-agent) Why is it necessary to eval the output of ssh-agent? Why can't I just run it?
jx12345
  • 1,640
143
votes
3 answers

Pass command line arguments to bash script

I am new to bash script programming. I want to implement a bash script 'deploymLog', which accepts as input one string argument(name). [root@localhost Desktop]# ./deploymLog.sh name here I want to pass the string argument(name) through command line…
chinchu
143
votes
7 answers

When is xargs needed?

The xargs command always confuses me. Is there a general rule for it? Consider the two examples below: $ \ls | grep Cases | less prints the files that match 'Cases', but changing the command to touch will require xargs: $ \ls | grep Cases |…
Zaid
  • 10,642
143
votes
12 answers

Is there a simple linux command that will tell me what my display manager is?

Is there a simple linux command that will tell me what my display manager is? I'm using Xfce. Are different desktop environments usually affiliated with different display managers?
ptrcao
  • 5,635
143
votes
6 answers

Setting a name for a screen session

Is there a way to give a particular name to a unix screen session? For instance, say I'm running the same program multiple times, each with different parameters and I want to tell which one is which.
well actually
  • 3,225
  • 5
  • 22
  • 11
142
votes
4 answers

Is there a ".bashrc" equivalent file read by all shells?

Is ~/.bashrc the only place to specify user specific environment variables, aliases, modifications to PATH variable, etc? I ask because it seems that ~/.bashrc seems to be bash-only, but other shells exist too…
Stefan
  • 25,300
142
votes
23 answers

Is there a way to get the min, max, median, and average of a list of numbers in a single command?

I have a list of numbers in a file, one per line. How can I get the minimum, maximum, median and average values? I want to use the results in a bash script. Although my immediate situation is for integers, a solution for floating-point numbers…
Peter.O
  • 32,916
142
votes
8 answers

Long line wrapping in Nano

When editing an authorised_keys file in Nano, I want to wrap long lines so that I can see the end of the lines (i.e tell whose key it is). Essentially I want it to look like the output of cat authorised_keys So, I hit Esc + L which is the meta key…
codecowboy
  • 3,442
141
votes
4 answers

What is the difference between reboot , init 6 and shutdown -r now?

I just want to know difference between in reboot init 6 shutdown -r now and which is the safest and the best?
Rahul Patil
  • 24,711
141
votes
5 answers

Difference between /bin and /usr/bin

I read this up on this website and it doesn't make sense. http://rcsg-gsir.imsb-dsgi.nrc-cnrc.gc.ca/documents/basic/node32.html When UNIX was first written, /bin and /usr/bin physically resided on two different disks: /bin being on a smaller…
whoami
  • 3,870