Questions tagged [shell]

A shell is terminology for a command-line interpreter most commonly used with Unix-like operating systems, but also used to interact with GUI-based operating systems in a more granular fashion. Not only does it allows the user to run programs from a text interface, but frequently offers basic programming features such as variables, substitution, output redirection, and wildcards.

A shell is terminology for a command-line interpreter most commonly used with Unix-like operating systems, but also used to interact with GUI-based operating systems in a more granular fashion.

Not only does it allows the user to run programs from a text interface, but frequently offers basic programming features such as variables, substitution, output redirection, and wildcards.

The name was first used by Unix operating system for an interpreter used for command prompt, but currently the term shell refers to BASH(Bourne Again SHell) and other command prompt interpreters too.

1348 questions
547
votes
5 answers

What is the difference between double and single square brackets in bash?

I just wondered what exactly the difference between [[ $STRING != foo ]] and [ $STRING != foo ] is, apart from that the latter is POSIX-compliant, found in sh and the former is an extension found in bash.
0x89
  • 6,465
  • 3
  • 22
  • 14
222
votes
14 answers

Shell command to monitor changes in a file

I know there was a command on Unix that I could use to monitor a file and see changes that are getting written to it. This was quite useful especially for checking log files. Do you know what it is called?
Sebastian Hoitz
  • 3,169
  • 3
  • 24
  • 19
183
votes
10 answers

What is "-bash: !": event not found"

Try executing the following under a bash shell echo "Reboot your instance!" On my installation: root@domU-12-31-39-04-11-83:/usr/local/bin# bash --version GNU bash, version 4.1.5(1)-release (i686-pc-linux-gnu) Copyright (C) 2009 Free Software…
Maxim Veksler
  • 2,725
  • 10
  • 28
  • 32
163
votes
8 answers

What does 'set -e' do, and why might it be considered dangerous?

This question has appeared on a pre-interview quiz and it's making me crazy. Can anyone answer this and put me at ease? The quiz has no reference to a particular shell but the job description is for a unix sa. again the question is simply... What…
egorgry
  • 2,871
  • 2
  • 23
  • 21
152
votes
19 answers

How to add a timestamp to bash script log?

I have a constantly running script that I output to a log file: script.sh >> /var/log/logfile I'd like to add a timestamp before each line that is appended to the log. Like: Sat Sep 10 21:33:06 UTC 2011 The server has booted up. Hmmph. Is there…
Antonius Bloch
  • 4,680
  • 6
  • 29
  • 41
128
votes
2 answers

Colors in bash after piping through less?

When I have dircolors defined life is full of... color. When I pipe ls through less to scroll around I lose the colors. Any suggestions?
MathewC
  • 6,957
  • 9
  • 39
  • 53
124
votes
8 answers

How can I kill all stopped jobs?

When I try to exit from my Linux server I get the message: There are stopped jobs. : Is there a single command to kill these?
yazz.com
  • 7,193
  • 15
  • 38
  • 39
116
votes
5 answers

What's the difference betwen the single dash and double dash flags on shell commands?

I'm new to working in the shell and the usage of these commands seems arbitrary. Is there a reason one flag has a single dash and another might have a double dash?
kylex
  • 1,421
  • 5
  • 14
  • 18
114
votes
8 answers

How to run command as user who has /usr/sbin/nologin as Shell?

All I need to do is to run a specific script as a particular user who does have the nologin/false shell indicated in /etc/passwd. I would run the script as root and this should run as another user. Running: ~# su -c "/bin/touch /tmp/test"…
Tommaso
  • 1,161
  • 2
  • 8
  • 4
106
votes
6 answers

How to let 'cp' command don't fire an error when source file does not exist?

I'm using Mac OS X. I'm trying to copying some files with cp command for a build script like this. cp ./src/*/*.h ./aaa But this command fires an error if there is no .h file in ./src directory. How to make the command don't fire the error? (silent…
Eonil
  • 10,459
  • 16
  • 36
  • 54
103
votes
6 answers

Adding a directory to $PATH in CentOS?

We just got our new server(s) up and we're running CentOS on them all. After successfully installing Ruby Enterprise Edition, I would now like to add the REE /bin (located at /usr/lib/ruby-enterprise/bin) directory to make it the default Ruby…
vonconrad
  • 1,281
  • 2
  • 9
  • 9
100
votes
7 answers

Is there a way to do a remote "ls" much like "scp" does a remote copy?

Is there a way to do a remote "ls" much like "scp" does a remote copy in a standard linux shell?
yazz.com
  • 7,193
  • 15
  • 38
  • 39
77
votes
7 answers

How do I join two named pipes into single input stream in linux

Using the pipes (|) feature in Linux I can forward chain the standard input to one or several output streams. I can use tee to split the output to separate sub processes. Is there a command to join two input streams? How would I go about this? …
Brad
73
votes
3 answers

What is the difference between unlink and rm?

Is unlink any faster than rm?
Marcin
  • 833
  • 1
  • 6
  • 4
70
votes
9 answers

Command to prepend string to each line?

Looking for something like this? Any ideas? cmd | prepend "[ERRORS] " [ERROR] line1 text [ERROR] line2 text [ERROR] line3 text ... etc
user14645
  • 1,590
  • 2
  • 13
  • 17
1
2 3
89 90