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, …).

learn more… | top users | synonyms (1)

1
vote
1answer
53 views

Is it possible to create a Linux environment without a traditional command shell?

i.e. Using something like IPython, re.pl, or somesuch as a login shell, instead of bash/ksh/etc. Using initscripts, etc. written in Python or some other scripting language, and making no use of ...
0
votes
1answer
33 views

How to move cron commands into a script?

Can someone give me an example that shows how to put Cron commands into a script? Using these commands as an example: find /home/network/public_1 -type f -ctime -1 -exec ls -ls {} \; find ...
3
votes
1answer
44 views

Make program in a pipe to think it has tty

Test environment: $ mkdir testdir $ cd testdir $ echo | tee "file name" Now, ls will print file?name (under Ubuntu GNU bash, at least), while ls | cat will print file and name in separate lines. ...
0
votes
2answers
28 views

Rsync'ing system, exclude doesn't seem to work

I'm trying to make a full filesystem backup of a server through rsync, following this guide. I'm using the following command: rsync -aAXH --progress --delete --stats --exclude={\ "/dev/*",\ ...
0
votes
4answers
53 views

How to get process id of a command

We are running some command in batch mode. We need to do some more tasks once the existing command is done, so we need to wait until this command is done. For example: bsub -q gui -I calibre -drc ...
1
vote
1answer
91 views

How does Git change the shell prompt in Aptana Studio's Cygwin Terminal?

I'm running Aptana studio 3.3.2. The command echo $SHELL outputs /bin/sh. However there is no value for the PS1 environment variable which I would like to inspect. I cannot there is no .bash_profile ...
1
vote
1answer
38 views

Interactive Shell Session from Java

I want to run a series of commands from Java. I came across few forums that explain how to execute multiple commands using getRuntime().exec(command) and defining command as String[]. But I want to ...
0
votes
1answer
75 views

Copying files with multiple extensions

I would like to copy files with multiple extensions to a single destination directory. For example, I can use the following command to copy all .txt files in the working directory to a directory ...
2
votes
2answers
532 views

Assign Subshell background process pid to variable

I am currently starting a background process within a subshell and was wondering how can I assign its pid number to a variable outside the subshell scope? I have tried many different ways but MYPID ...
1
vote
1answer
23 views

Icon stops loading after the application restarts

I have a application which uses "self-restart" mechanism. It kills itself and runs again. When I run it first time (with .desktop file) it loads its icon correctly. The problem is that when it ...
1
vote
3answers
73 views

How to get the pid of a process and invoke kill -9 on it in the shell script? [duplicate]

I have an application server which we start by running this below command and as soon as we run the below commnad, it will start my application server /opt/data/bin/test_start_stop.sh start And to ...
1
vote
1answer
41 views

du skip symbolic links

I cannot find an example of what I want to do and, from what I'm reading, the default behavior of du on my system is not the proper default behavior. If I ls my /data folder, I see (removing the ...
-2
votes
0answers
19 views

UNIX .vimrc settings not preserved after running Screen command

After the terminal window first appears, I run Screen to split the screen horizontally. I notice however that my settings for VIM in .vimrc are not "preserved". Is there a way to fix this? I am ...
1
vote
1answer
77 views

Why are UNIX shells like this and how can I work around it?

One of the things I've noticed about BASH and other UNIX shells is that, by default and when used in typical ways, they spawn subshells for almost everything. e.g. foo=$(grep "someword" ...
0
votes
1answer
42 views

Changing my default directory in passwd changes my prompt

I don't understand what's happening in this scenario. I changed the home directory of a user by editing the /etc/passwd file instead of using usermod -d. It worked: the default directory wasn't ...
0
votes
3answers
43 views

Shell pattern matching vs. regular expressions occurence [duplicate]

I am relatively new to Unix, and I stumbled across one curiosity. Some shell constructs like case or find, employ pattern matching, but it is not quite regex. Other commands, like ed, sed, vi, and ...
2
votes
2answers
46 views

List of subdirectories that contains a particular file name

I am wondering if i can do this in a single shell command. I am in home directory and want to find a list of subdirectories that contains a particular file. The file name and the depth is always ...
0
votes
1answer
50 views

How do I switch from bash to zsh? [duplicate]

I can start zsh with zsh. How can I make it be the default for new terminal windows? Will it be ok to copy my .bashrc to .zshrc to get things like my customized PS1 prompt.
-2
votes
6answers
168 views

How to change to normal user in the command line when logged in as the root user?

I log into an system through root via ssh. How do I become the normal user or another user on the system?
1
vote
3answers
109 views

How to find md5sum of files on remote machines by doing ssh?

I am running my below shell script on machineC which gets the md5sum of my files in my PRIMARY directory in machineC itself. #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do ...
0
votes
1answer
40 views

Permission denied while getting the md5sum of a file using shell script?

I am running my below shell script which gets the md5sum of a files in my PRIMARY directory #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do local_md5sum=/usr/bin/md5sum ...
2
votes
1answer
50 views

Bash - how to make explicit operator precedence without creating a subshell

I'm sure this is posted somewhere, but I haven't been able to find it. In Bash, how does one specify operator precedence (aka command grouping) without creating a subshell? In most other languages ...
3
votes
1answer
30 views

More shell scripts than one in one text file?

I am learning shell scripting for my introductory UNIX course at my university, and I`m curious if is it possible to have more than one shell script in one text file. What I mean by that is, for ...
0
votes
2answers
36 views

Add space after 8 characters then add space after every 4 characters

Here is the sample input: AbbigailAbieAbbyAbbi Using sed, I have separated them into 4 characters but seems like I got a problem because I have to separate the first 8 characters first then add ...
0
votes
1answer
48 views

How to invoke shell function in string? (bash)

I want to invoke shell function in string. Here is my use case: function envfoo() { env ENV_FOO=foo $@ } function envbar() { env ENV_BAR=bar $@ } $ envfoo env |egrep ENV_ ENV_FOO=foo $ ...
1
vote
1answer
19 views

Increase character width in Ubuntu server shell?

Is there any way to increase the character width from 80 to something higher in the shell in an Ubuntu server?
1
vote
2answers
157 views

I accidentally GZIPed a whole bunch of files, one by one, instead of using tar(1). How can I undo this mess?

I'm new to the gzip command, so I googled some commands to run so I can gzip an entire directory recursively. Now while it did that, it converted each of my files to the gzip format and added .gz to ...
8
votes
4answers
473 views

How do I remove spaces from shell variables?

I have done the following at command line: $ text="name with space" $ echo $text name with space I am trying to use tr -d ' ' to remove the spaces and have a result of: namewithspace I've tried ...
5
votes
3answers
134 views

I am trying to find a better/easier way to count alphabetic characters in a file or shell variable

I have a file containing the following text: we are going to write something 1 2 3 wc tells me I have 1 line 9 words and 38 characters. I'm looking to count the 26 letters only (a-z, no numbers or ...
5
votes
3answers
140 views

Bash script error with strings with paths that have spaces and wildcards

I am having trouble getting the basics of Bash scripting down. Here's what I have so far: #!/bin/bash FILES="/home/john/my directory/*.txt" for f in "${FILES}" do echo "${f}" done All I want to ...
0
votes
3answers
137 views

bash find using variable

I have an issue I don't understand. It is simple and it should work, but it doesn't. =EDITED exactly what I can see from terminal= I have a list of filenames: [molni@archlinux picasa_album]$ cat LIST ...
2
votes
1answer
42 views

how to execute a shell built-in if find found certain files

In general, if we want to execute a command if find identifies files corresponding to certain specs, we can use -exec. But in my case I want to exit the shell/script if find found a match and -exec ...
1
vote
2answers
55 views

Pass arguments to a command run by another user

I have a bash script that is supposed to take some arguments and then run in a different user: test.sh #!/bin/bash sudo su user2 <<'EOF' echo $1 EOF However it prints blank: $ ./test.sh ...
0
votes
2answers
32 views

How can I sudo su and change directory just after?

I would like to create an alias that does something like this: alias userYYY='sudo su userYYY; cd /a/path/that/only/userYYY/has/access' So then from my command line, I am logged in with a sudoer ...
0
votes
0answers
32 views

How to get diff for HTML reports?

echo "New defects" echo "===============================" n=0 def_num=0 while read line; do n=$((++n)) if echo $line | grep '^[[:space:]]*>' &>/dev/null; then if [ $(($n % ...
3
votes
4answers
58 views

How can I get the first match from wildcard expansion?

Shells like Bash and Zsh expand wildcard into arguments, as many arguments as match the pattern: $ echo *.txt 1.txt 2.txt 3.txt But what if I only want the first match to be returned, not all the ...
1
vote
3answers
86 views

shell script to run on boot on Mac OS X does not run all commands

On OS X, I am trying to use lingon to run a shell script upon booting. I have a file ~/desktop/_admin/boot/bootdocker.sh: #!/bin/bash boot2docker up export DOCKER_HOST=tcp://192.177.59.103:2475 My ...
4
votes
3answers
140 views

Get PID of any command in backgrounded piped sequence of commands

If, in bash, I execute: cmd1 | cmd2 | ... | cmdi | ... | cmdn & where the cmd{1..n} may not be distinct, how do I get the PID of cmdi? Alternatively, how can I signal the cmdi process? (For ...
6
votes
2answers
274 views

Compare two files and print matches

Is there anyway to get this through Unix shell scripting? I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return ...
7
votes
4answers
269 views

Can I specify a redirected input before a compound command?

Bash lets you specify a redirected input before a command: $ <lines sed 's/^/line: /g' line: foo line: bar Bash also lets you redirect input to a compound command like a while loop: $ while ...
9
votes
1answer
319 views

Is it possible to use `find -exec sh -c` safely?

I'm trying to use find to echo 0 into some files, but apparently this only works with sh -c: find /proc/sys/net/ipv6 -name accept_ra -exec sh -c 'echo 0 > {}' \; But using sh -c with find -exec ...
-7
votes
1answer
48 views

Questions about UNIX [closed]

Which of the following UNIX command is used to find all of the files which have been accessed within last 30 days. find . -stime -30 -exec || \; |more find . -atime -30 -exec || \; |more find . ...
2
votes
2answers
49 views

Reference a path name in `find` output results

What I would like to do is to be able to reference a find path name result as a parameter to another command without laboriously typing the full path name. Example: $ find -name testfile path1 ...
2
votes
2answers
82 views

Shell script throws a not found error when run from a sh file. But if entered manually the commands work

Im trying to use the following script to generate a sitemap for my website. When I run it as sh thsitemap.sh I get an error like this and creates an empty sitemap.xml file : thsitemap.sh: 22: ...
3
votes
1answer
65 views

How do I diff the outputs of two commands?

How can I use the diff command to compare 2 commands' outputs? Does something like this exist? diff ($cat /etc/passwd) ($cut -f2/etc/passwd)
1
vote
1answer
76 views

What is happening while executing this command cd / | vi?

When I execute the command cd / | vi, it goes to the vi editor. When I type any command it does not display the command but it gets executed and the command that is executed is not shown in the ...
1
vote
1answer
30 views

fuser output looks ambiguous

I am using fuser the output is like this: $ fuser / /: 1354rc 1362r 1370rc 1371rc 1395rc 1399rc 1403rc 1410rc 1414rc 1428r 1451rc 1458rc 1470rc 1472rc 1477rc 1480rc ...
0
votes
0answers
50 views

What is the difference between double quotes (“”) and single quotes ('')? [duplicate]

I really do not know the usage of " and '. I want to know usage of " and '. What is the difference between echo "hi" and echo 'hi'.
-4
votes
1answer
67 views

UNIX homework question regarding piping output, I don't understand what it's asking?

Basically, I need to come up with a command that sends the contents of a file xxx into a program yyy, then the output is piped to the input of another program zzz, where the output is appended to a ...
1
vote
0answers
49 views

C Shell unfreezing using right click [closed]

I know almost nothing about Unix. I use commands like cd, rm, mkdir, cp, get, put, etc., and then simply run scripts that other people have written. I had opened C-Shell and was running a script and ...