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.

1366 questions
118
votes
5 answers

What's the difference between 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,443
76
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,690
  • 2
  • 15
  • 17
11
votes
7 answers

Using telnet in shell script

I use the telnet command to check if MySQL port is responding. telnet 10.10.10.24 3306 I use the ctrl character to disconnect. This is working as expected. How do I use this command in shell script?
shantanuo
  • 3,619
5
votes
4 answers

What is the purpose of "source" (.) as a shell command?

What is the difference between these two commands? . filename # (A) and filename # (B) And how is this command related? ./filename # (C) Note: The # and the rest of the line after it are comments.
3
votes
2 answers

Easy way to store and access commonly used commands?

I have a bunch of commands that I commonly use. For example: du -h --max-depth=1 /home Unfortunately, my brain has very little room left for these sorts of things. I currently keep a text file on my desktop for jotting down these commands -- but…
3
votes
3 answers

How to continue execution of shell script after calling other shell script with `exec`?

I have a script: ACTION="build" env -i exec ./makelib.sh Release "${ACTION}" env -i exec ./makelib.sh Debug "${ACTION}" Second exec does not execute. Why, and how can I execute it?
Eonil
  • 10,649
3
votes
4 answers

How do I make a shell script produce the equivalent of a keypress?

I want to write a shell script that does what a recorded macro would do and replay key-presses. In particular, to produce ctrl+a. Is this possible? I've tried things like echo \0141, but it just says there's no command \0141.
interstar
  • 1,321
2
votes
1 answer

Shell script won't run ruby script file

My shell script (my_shell.sh) won't run the ruby script (ruby_script_1.rb) in it. my_shell.sh: #!/bin/sh # Invoke the ruby script here ./ruby_script_1.rb It could not find where the ./ruby_script_1.rb is, thus errors: # sudo my_shell.sh : No such…
1
vote
1 answer

What does #!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d' do?

While troubleshooting a failed Docker deploy, I noticed this line was in the Dockerfile. What does the following line do exactly? #!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
david
  • 135
  • 7
1
vote
5 answers

grep command to search for a pattern in multiple files and list the files ordering by date

I have a requirement to search for a pattern in multiple files and get the latest file for further processing. I am trying to do this in a shell script. I was trying to do it as follows file=`grep -lh | tail -1` But grep is…
Ashu
1
vote
4 answers

Wildcards not being substituted

#!/bin/bash loc=`echo ~/.gvfs/*/DCIM/100_FUJI` rm -f /mnt/fujifilmA100 ln -s "$loc" /mnt/fujifilmA100 For some reason the variable * doesn't get substituted with the only possible value and gets given the value /home/chris/.gvfs/*/DCIM/100_FUJI.…
Casebash
  • 133
1
vote
2 answers

delete files which are not inside another folder

I have two directories called thumb and thumb2. They contain the same file names but are different in size. Unfortunatelly there are some files in thumb2 that are not in thumb which need to be removed. $ ls ../thumb2 | wc -l 199030 $ ls ../thumb |…
merlin
  • 2,172
1
vote
1 answer

What are the advantages of fish shell?

What are the advantages of fish shell?
NES
  • 215
1
vote
2 answers

Accessing all variables passed to a shell script from a given index

How can I access the values within $@ starting from the third one? Right now I'm passing them from three to nine, but I think theres a better way: while getopts ":n" opt "$3 $4 $5 $6 $7 $8 $9"; do
1
vote
2 answers

ls -m with more info?

i need to store directory information in a way that i can parse as json. when i do ls -m it gives me comma separated values but no user/group/size info. bash-3.2$ ls -mp 100CANON/, 2009-11-27_1540.swf, 2009-11-27_1546.swf, 2009-11-27_1551.swf,…
Devrim
  • 1,187
1
2