Questions tagged [shell]

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.

Filter by
Sorted by
Tagged with
778 votes
5 answers
398k views

Difference between nohup, disown and &

What are the differences between $ nohup foo and $ foo & and $ foo & $ disown
Lesmana's user avatar
  • 27.2k
1 vote
1 answer
590 views

CH3MNAS Fun Plug and NZBget. Cannot launch NzbGet 0.7, word unexpected

I have un-tarred the nzbget0.70 debug version and have put it in the /ffp/bin dir. and I have a config file in the /ffp/etc/ dir but when I try to run it, I get the following: root@NAS:/mnt/HD_a2/...
JP Hellemons's user avatar
142 votes
6 answers
165k views

How to pass parameters to an alias?

For bash script, I can use "$@" to access arguments. What's the equivalent when I use an alias?
prosseek's user avatar
  • 8,488
3 votes
2 answers
3k views

Forcing emacs to run with `-nw` when called from terminal

note: This question might have been asked before ( I think I saw it somewhere), but a quick search did not reveal anything. I would like to tell the difference when a command is run from a shell. ...
Stefan's user avatar
  • 25.1k
6 votes
3 answers
3k views

Deleting lots of files

I accidentally created 8 million files and every time I'm trying to delete them the server almost dies because of the rm process eating all disk IO (the server is remote without console). Should ...
Jonas Lejon's user avatar
49 votes
2 answers
72k views

How do I delete all files with a given name in all subdirectories?

I want to delete all files with a given name in all the subdirectories of my home directory. I tried: rm -r file in my home directory, but it didn't work because that file doesn't exist in that ...
oadams's user avatar
  • 2,325
5 votes
2 answers
8k views

Why am I getting a syntax error with my Shell arithmetic?

I have a problem with a linux shell script (sh). I'm trying to write a script that calculates combinations, but I think I get overflows when trying to calculate faculties. So, I'm trying another ...
3sdmx's user avatar
  • 151
2 votes
0 answers
376 views

How can I check which shell I am currently using? [duplicate]

Possible Duplicate: How to test what shell I am using in a terminal? An echo $SHELL will only display the value of the SHELL variable which would indicate the default shell on the system. But I ...
Lazer's user avatar
  • 34.7k
5 votes
3 answers
6k views

Make terminal text color different when in ssh session

Is there a way to make my terminal (konsole) display different text colors when I'm in an ssh session WITHOUT modifying the remote host's color configuration? Like, maybe automatically switching to a ...
Falmarri's user avatar
  • 12.9k
29 votes
4 answers
32k views

touch: cannot touch `foo': No such file or directory

What could cause touch to fail with this error message? touch: cannot touch `foo': No such file or directory Note that an error due to incorrect permissions looks different: touch: cannot touch `...
Lorin Hochstein's user avatar
55 votes
1 answer
28k views

Difference between shell variables which are exported and those which are not in bash

Bash seems to differentiate between variables which have been exported and those which have not. example: $ FOO=BAR $ env | grep FOO $ set | grep FOO FOO=BAR set sees the variable but env does not. ...
Lesmana's user avatar
  • 27.2k
6 votes
2 answers
990 views

How can I display the time when a command was executed in my bash prompt?

Currently my bash prompt looks like this $ echo $PS1 # \[\e[34m\][\t]\[\e[0m\] \[\e]0;\w\a\]\[\e[34m\]\u@\h: \[\e[34m\]\w\[\e[0m\]\n$ $ The problem is that \t will only display the time when the ...
Lazer's user avatar
  • 34.7k
6 votes
4 answers
379 views

How could I simplify this command to only use awk?

awk '/user/ {print $1 }' /etc/userdomains | sed 's/://' the format of /etc/userdomains is domain.tld: user otherdomain.tld: otheruser
xenoterracide's user avatar
10 votes
3 answers
7k views

How do I take a list and remove it from a file?

I have a long list of domain names that I need to remove from /etc/remotedomains. They're probably not in any particular order in the file. Each domain is on one line. How could I iterate through the ...
xenoterracide's user avatar
123 votes
8 answers
230k views

Grabbing the first [x] characters for a string from a pipe

If I have really long output from a command (single line) but I know I only want the first [x] (let's say 8) characters of the output, what's the easiest way to get that? There aren't any delimiters.
xenoterracide's user avatar
6 votes
2 answers
2k views

How to make sure that I use the latest version of bash?

I just setup bash v4.1.0 on my machine. The old version is under /bin/bash. Is there a way to use the newer version of bash without replacing the old one from /bin? I want the newer version to be ...
Lazer's user avatar
  • 34.7k
9 votes
2 answers
6k views

What are the new features available to bash 4?

I was using bash3 up to now, and just got a copy of the latest version $ ./bash --version GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu) Copyright (C) 2009 Free Software Foundation, Inc. ...
Lazer's user avatar
  • 34.7k
25 votes
4 answers
14k views

Share aliases and PATH setting between zsh and bash

The shell that I normally use is zsh. I have several aliases to enable color in some programs such as ls and grep. I've also set my custom path so that I can execute programs in non-standard place (...
phunehehe's user avatar
  • 20.1k
5 votes
3 answers
205 views

How do I remove every file that has x in its title?

I have a lot of directory where there are hundreds of files. In every directory there are pairs of my_file-01.jpg and my_file-€01.jpg I want to remove every file that contains € sign in its title: ...
dag729's user avatar
  • 241
57 votes
5 answers
20k views

What are the fundamental differences between the mainstream *NIX shells? [closed]

What are the fundamental differences between the mainstream *NIX shells and what scenarios might prompt you to use one over the other? I understand that some of it probably comes down to user ...
conorgriffin's user avatar
  • 1,523
18 votes
4 answers
44k views

Remove end of line characters from stdout? Multiple lines into a single line

I have a script which outputs the following text. This is the output from a Netopia 2210-02 ADSL2 modem. ADSL Line State: Up ADSL Startup Attempts: 1 ADSL Modulation: DMT ADSL Data ...
Stefan Lasiewski's user avatar
88 votes
3 answers
38k views

What is the bash shortcut to change to the previous directory?

Sadly, I only learned about this last year by stumbling upon it randomly on the internet. I use it so infrequently that I always forget what it is by the time I need it again. How do you change to ...
hobodave's user avatar
  • 1,183
5 votes
3 answers
3k views

renaming files without the **rename** command

I have a directory of files, Measurements Panama 2009-03-22 Session1.xml Measurements Panama 2009-03-22 Session2.xml Measurements Panama 2009-03-22 Session3.xml Measurements Panama 2009-03-22 ...
Vass's user avatar
  • 5,311
8 votes
6 answers
4k views

How can I reproduce commands run on one machine on another machine?

I would like to install some software on a linux-machine that I have run in VirtualBox. Then I would like to do the same thing on a linux-VPS. I think that I can save all commands that I run using ...
Jonas's user avatar
  • 1,593
78 votes
8 answers
131k views

grep and tail -f?

Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
xenoterracide's user avatar
40 votes
5 answers
14k views

How to know the "level" of shells I am in?

If I open a terminal like xterm I will have a shell. Then if I use ssh or zsh I will have another "level" of shell. Is there a way to know how many times I have to Ctrl+D or type exit to exit all of ...
phunehehe's user avatar
  • 20.1k
5 votes
2 answers
1k views

RS232 chat. Simplest way?

I'm working in a project in which I will have to deal with serial communications. For testing, I want make to 2 computers speak to each other (with my interaction) via RS232. Will the next thing work?...
Tomas's user avatar
  • 1,024
1 vote
1 answer
2k views

error using "du" command

I am on the university machine trying to estimate the disk usage I have on my space I do du -csh ./ from the begining of my account, but an error is given that ./Yesterday/Yesterday is not a device, ...
Vass's user avatar
  • 5,311
6 votes
1 answer
9k views

Read space as input in shell script [duplicate]

How can I give space " " as input in shell script ? Ex : echo " Enter date for grep... Ex: Oct 6 [***Double space is important for single date***] (or) Oct 12 " read mdate echo $mdate I get the ...
Kumar's user avatar
  • 893
40 votes
5 answers
26k views

Save complete GNU screen session state

Is it possible to persist the "state" of a GNU screen window (or just a standard shell) so that I can reload everything after a reboot: The number of opened shells The name of each shell The current ...
Barthelemy's user avatar
  • 5,155
286 votes
12 answers
438k views

How do I convert an epoch timestamp to a human readable format on the cli?

How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).
xenoterracide's user avatar
6 votes
3 answers
800 views

Correct textual name for <<

I've just come across the << command, used like so: cat > outfile.txt <<EOF Multi-line content that will be written to outfile.txt EOF Now, I've no idea what this is called, but I'd ...
me_and's user avatar
  • 1,141
17 votes
7 answers
6k views

Is it bad practice to set root's shell to something other than the default?

Once a friend of mine (who is an experienced Unix/Linux user) told me that setting root's shell to something other than sh (i.e bash or zsh) might create problems, because some script might assume ...
phunehehe's user avatar
  • 20.1k
20 votes
5 answers
29k views

how to pass the result of `find` as a list of files?

The situation is, I have an MP3 player mpg321 that accepts a list of files as argument. I keep my music in a directory named "music", in which there are a few more directories. I just want to play all ...
phunehehe's user avatar
  • 20.1k
10 votes
1 answer
13k views

how to view a directory's permission

What is the command with which you can directly view the permission bits of a directory?
deostroll's user avatar
  • 307
4 votes
3 answers
1k views

`$XAUTHORITY` appears from 'nowhere' on su+tmux

When I switched from su+bash to su+tmux+zsh I noticed that I get the $XAUTHORITY variable defined as /root/.xauthXXXXXX where XXXXXX are 6 random alphanumeric characters. With the previous ...
Maciej Piechotka's user avatar
1 vote
1 answer
826 views

how to convert ^I character

I have a text file like this: info Some info here In which when I use cat -A display this: info^I Some info here How do I edit this so I'll get something like this instead: info<space>-<...
Coding District's user avatar
1 vote
2 answers
605 views

Problematic build script with quotes

Hi I'm trying to create a build script that executes these commands: cd libiconv ../../src/libiconv/configure --prefix=/home/ruben/mingw64/build/gcc-libs \ --host=x86_64-...
rubenvb's user avatar
  • 370
0 votes
0 answers
351 views

bash: recall command by typing some characters of it [duplicate]

Possible Duplicate: best way to search my shell's history In MSDOS I have the option to start typing some characters of a previous command and then pressing F8 it will search the command ...
user avatar
3 votes
2 answers
2k views

Extending history search in zsh

How to extend Ctrl+R search in zsh? It cannot find entry despite it is in history file. Edit: My .zshrc: setopt AUTO_CD setopt CORRECT_ALL setopt EXTENDED_GLOB # History SAVEHIST=10000 HISTFILE=~/....
Maciej Piechotka's user avatar
25 votes
11 answers
25k views

Tool in UNIX to subtract dates

Is there any tool in Solaris UNIX (so no GNU tool available) to subtract dates? I know that in Linux we have gawk that can subtract one date from another. But in Solaris the maximum we have is nawk (...
jyz's user avatar
  • 657
7 votes
2 answers
3k views

dash compatibility to bash

Wikipedia says that dash executes faster than bash. My question is, if I set /bin/sh to dash, will all scripts that use /bin/sh in their shebang line that was intended for bash work under dash?
uray's user avatar
  • 3,840
6 votes
2 answers
913 views

modify path globally

Is there a standard for $PATH and the order of things that are supposed to be in there? out of the box Arch Linux doesn't have /usr/local/bin in the $PATH. I want to add it but I'm not sure if there's ...
xenoterracide's user avatar
49 votes
10 answers
83k views

Grabbing the extension in a file name

How do I get the file extension from bash? Here's what I tried: filename=`basename $filepath` fileext=${filename##*.} By doing that I can get extension of bz2 from the path /dir/subdir/file.bz2, but ...
uray's user avatar
  • 3,840
8 votes
1 answer
1k views

Whenever I type some wrong command, my terminal tries to run that command in the background

Something strange started happening to my terminal. Whenever I type some wrong command it tries to run that command in the background. hegeek@colinux: ~# l [9]+ Stopped l thegeek@colinux: ~# ...
Hemant's user avatar
  • 6,872
3 votes
1 answer
1k views

Emacs mode in zsh: M-b M-f etc. show weird symbols

I have set up zsh to use emacs mode. But typing Alt+f or Alt+b inserts weird symbols (accented letters and so on), rather than moving around by word in the shell like it should. Since I don't ever ...
Seamus's user avatar
  • 3,573
2 votes
3 answers
418 views

Directory filenames with sed with whitespaces

I'm working on a script and I'm stuck, even with the help of the google. Here's my code: for FOLDER in `find . -type d | sed "s#^.#$(pwd)#" | sed 's/ /\ /g'` do echo "$FOLDER" done This will ...
MonkeyWrench32's user avatar
23 votes
10 answers
44k views

How do I change folder timestamps recursively to the newest file?

I was wondering if anyone knows how to change the timestamps of folders recursively based on the latest timestamp found of the files in that folder. So for example: jon@UbuntuPanther:/media/media/...
MonkeyWrench32's user avatar
486 votes
10 answers
207k views

How do I delete a file whose name begins with "-" (hyphen a.k.a. dash or minus)?

How do you remove a file whose filename begins with a dash (hyphen or minus) -? I'm ssh'd into a remote OSX server and I have this file in my directory: tohru:~ $ ls -l total 8 -rw-r--r-- 1 me ...
Astra's user avatar
  • 4,963
4 votes
3 answers
3k views

Understanding sudoers:

I have a Unix script which creates a temporary log file, say tempfl.log. When this file is created it has permission rw-r--r--. There is a line chmod 0440 /etc/sudoers tempfl.log 2>&1 But ...
randeepsp's user avatar
  • 153