Most Popular

1500 questions
350
votes
21 answers

How can I get a count of files in a directory using the command line?

I have a directory with a large number of files. I don't see a ls switch to provide the count. Is there some command line magic to get a count of files?
Blake
  • 3,687
347
votes
27 answers

How can I get my external IP address in a shell script?

I need to find my external IP address from a shell script. At the moment I use this function: myip () { lwp-request -o text checkip.dyndns.org | awk '{ print $NF }' } But it relies on perl-libwww, perl-html-format, and perl-html-tree being…
347
votes
4 answers

What do the fields in ls -al output mean?

The ls -al command shows the following output; -rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe What are all the fields in the preceding display?
Mr. White
  • 3,657
343
votes
5 answers

Sort and count number of occurrence of lines

I have Apache logfile, access.log, how to count number of line occurrence in that file? for example the result of cut -f 7 -d ' ' | cut -d '?' -f 1 | tr '[:upper:]' '[:lower:]' is a.php b.php a.php c.php d.php b.php a.php the result that I want…
Kokizzu
  • 9,699
342
votes
7 answers

How do I equally balance tmux(1) split panes?

I'm looking for a behavior that is similar to how vim(1) handles its split windows with ^w =. I know tmux(1) has predefined layouts with ^b Meta[1-5], but this likely does not have the layout that I am currently using. When splitting a window, it…
341
votes
18 answers

Is it possible to see cp speed and percent copied?

I'm having problems when copying large files using nautilus (it gets stuck). I need to copy, using cp. I would like to know if there are any parameters that shows the % copied and also the transfer speed.
user27807
341
votes
4 answers

How to get the pid of the last executed command in shell script?

I want to have a shell script like this: my-app & echo $my-app-pid But I do not know how the get the pid of the just executed command. I know I can just use the jobs -p my-app command to grep the pid. But if I want to execute the shell multiple…
David S.
  • 5,589
341
votes
2 answers

How can I instruct yum to install a specific version of package X?

If there are two (or more) versions of a given RPM available in a YUM repository, how can I instruct yum to install the version I want? Looking through the Koji build service I notice that there are several versions.     
slm
  • 369,824
340
votes
5 answers

What's the story behind Super Cow Powers?

As we know, apt-get has Super Cow Powers and aptitude does not: $ apt-get --help | grep -i cow This APT has Super Cow Powers. $ aptitude --help | grep -i cow This aptitude does not have Super Cow Powers. and…
derobert
  • 109,670
338
votes
5 answers

How can I get the current working directory?

I want to have a script that takes the current working directory to a variable. The section that needs the directory is like this dir = pwd. It just prints pwd how do I get the current working directory into a variable?
user104976
337
votes
5 answers

Why doesn't my Bash script recognize aliases?

In my ~/.bashrc file reside two definitions: commandA, which is an alias to a longer path commandB, which is an alias to a Bash script I want to process the same file with these two commands, so I wrote the following Bash script: #!/bin/bash for…
Zaid
  • 10,642
335
votes
12 answers

How to terminate a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to terminate its process, then re-run the command. How can I terminate it? I haven't closed its shell window. But as you know it doesn't stop using…
334
votes
10 answers

How to split the terminal into more than one "view"?

From vi, if you issue the command :sp, the screen splits into two "views", allowing you to edit more than one file from the same terminal. Along those same lines, is there a way to have multiple shells open in the same terminal?
Justin Ethier
  • 16,806
333
votes
8 answers

How to reload udev rules without reboot?

How should one reload udev rules, so that newly created one can function? I'm running Arch Linux, and I don't have a udevstart command here. Also checked /etc/rc.d, no udev service there.
daisy
  • 54,555
332
votes
11 answers

how can I make cron run a job right now, for testing/debugging? without changing the schedule!

I have a cron job that is scheduled to run everyday, other than changing the schedule, is there any other way to do a test run of the command right now to see if it works as intended? EDIT: (from the comments) I know the command works fine when…
Ali
  • 6,943