Most Popular

1500 questions
112
votes
4 answers

What is meant by mounting a device in Linux?

I've heard the term "mounting" when referring to devices in Linux. What is its actual meaning? How it handling now unlike older versions? I haven't done that manually via the command-line. Can you give the steps (commands) for mounting a simple…
Renjith G
  • 5,888
112
votes
2 answers

How can I use `find` and sort the results by mtime?

I want to use find but sort the results reverse chronologically as with ls -ltr. Is this possible through any combo of flags or pipelines?
dan
  • 4,077
  • 5
  • 27
  • 34
112
votes
5 answers

What's the difference between eval and exec?

eval and exec are both built in commands of bash(1) that execute commands. I also see exec has a few options but is that the only difference? What happens to their context?
112
votes
6 answers

How to limit network bandwidth?

We are hosting an application on remote server. We need to test it with a limited network bandwidth (for users with bad Internet access). Can I limit my internet bandwidth? For instance: 128 KB per second. This question focuses on system-wide or…
112
votes
7 answers

Is there a basic tutorial for grep, awk and sed?

I've been a Linux user for a while, and I've a pretty decent understanding of most the common command line utilities. However, ones that come up and up again in relation to programming are grep, awk, and sed. About the only thing I've used grep for…
Macha
  • 3,790
112
votes
3 answers

How to make tree output only directories?

150 directories I can handle but 900 files is too many for a review. I've no manual entry for tree so maybe I can ask you if you know how to output only directories since files get too detailed? . ├── agreement.htm ├── appengine_admin │   ├──…
112
votes
7 answers

creating a tar archive without including parent directory

I am trying to create a graphical program for my script. Inside the script I use tar to create a tar archive. From the graphical program I get the full name of file that I want to create a tar archive. tar -cvf temp.tar…
112
votes
5 answers

If processes inherit the parent's environment, why do we need export?

I read here that the purpose of export in a shell is to make the variable available to sub-processes started from the shell. However, I have also read here and here that "Processes inherit their environment from their parent (the process which…
112
votes
1 answer

Why does my regular expression work in X but not in Y?

I wrote a regular expression which works well in a certain program (grep, sed, awk, perl, python, ruby, ksh, bash, zsh, find, emacs, vi, vim, gedit, …). But when I use it in a different program (or on a different unix variant), it stops matching.…
112
votes
8 answers

Show all the file up to the match

grep --before-context 5 shows 5 lines before the match. I want to show everything before the match. Doing grep --before-context 99999999 would work but it is not very... professional. How to show all the file up to the match?
111
votes
3 answers

How do I check if a file is a symbolic link to a directory?

I can check, if a file exists and is a symbolic link with -L for file in *; do if [[ -L "$file" ]]; then echo "$file is a symlink"; else echo "$file is not a symlink"; fi done and if it is a directory with -d: for file in *; do if [[ -d…
rubo77
  • 28,966
111
votes
1 answer

How do I force yum to install without prompting the user, using bash?

I'm writing a bash script to install php5.4 and I'd like to automate this for a test VM. The rpm command I have is: rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm yum install php54w Now, in the middle of this running, there is a user prompt…
Bradley
  • 1,519
111
votes
10 answers

shell command to get pixel size of an image

Is there a shell command that returns the pixel size of an image? I'm trying to produce an animated gif starting from different gifs with different sizes using convert (e.g. convert -delay 50 1.gif 2.gif -loop 0 animated.gif). The problem is that…
blue
  • 2,952
111
votes
6 answers

Birth is empty on ext4

I was just reading up on the Birth section of stat and it appears ext4 should support it, but even a file I just created leaves it empty. ~ % touch test slave-iv ~ % stat test.pl …
xenoterracide
  • 59,188
  • 74
  • 187
  • 252
111
votes
4 answers

How can I test for POSIX compliance of shell scripts?

Considering that POSIX is the closest thing to a common standard among all unices, I'm interested in knowing if there's a shell that supports it exclusively. While most modern shells provide support for POSIX (and will run POSIX compliant scripts…
rahmu
  • 20,023