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)

3
votes
1answer
1k views

Installing ksh as the standard shell in Redhat: Foolhardy?

I'm not a system administrator, but my organization is considering replacing /bin/sh in Red Hat Enterprise Linux 6+ with a hard link to /bin/ksh. How foolhardy would this be? The background to this ...
0
votes
2answers
46 views

How do I sort using the grep and sort command

I would like to create a sorted list of all TCP services found in the file /etc/services. Pipe the output of the command grep tcp /etc/services into the command sort. Redirect the output of this pipe ...
43
votes
6answers
40k views

How to add a newline to the end of a file?

Using version control systems I get annoyed at the noise when the diff says No newline at end of file. So I was wondering: How to add a newline at the end of a file to get rid off those messages?
2
votes
3answers
359 views

How to launch two threads in bash shell script?

I am trying to copy files from machineB and machineC into machineA as I am running my below shell script on machineA. If the files is not there in machineB then it should be there in machineC for ...
1
vote
5answers
46 views

grep for text that may or may not be present

Lets say I have a file batman; robin; superman; password = ""; wonderwoman green lantern if I want to check if there is a password present, i.e there is something entered in the "" . here is an ...
9
votes
6answers
6k views

How can I set my default shell to start up tmux

I would like my default bash shell to go straight into tmux instead of my always having to type tmux every time.
1
vote
1answer
29 views

Assign diff -y column names

I have two files and a shell script. File 1: Batman Superman John Snow Jack Sparrow Rob Stark File 2: Batman Ironman Superman Spiderman John Snow Arya Stark Jack Sparrow Rob Stark The hound ...
-2
votes
5answers
65 views

Resources to learn shell scripting [closed]

I have been using GNU/Linux for sometime now (Ubuntu and Fedora) and now I am trying to learn shell scripting from scratch. I would really appreciate if someone can guide me on choosing right ...
29
votes
7answers
12k views

How to test what shell I am using in a terminal?

How to check what shell I am using in a terminal? What is the shell I am using in MacOS?
0
votes
2answers
97 views

Running system bash command in PHP script - syntax error: unexpected T_LNUMBER

If anyone can shed some light on my issue that'd be great. Please don't down-vote me; I'm new to the language and the OS itself and I'm trying my best to research before asking questions, so any ...
5
votes
4answers
8k views

Processing bash variable with sed

Been banging my head off a wall on this bash variable LATLNG contains a latitude & longitude value in brackets like so (53.3096,-6.28396) I want to parse these into a variable called LAT and ...
8
votes
7answers
19k views

Which shell should I use - tcsh vs bash?

I have been using tcsh for a long time now. But whenever I am searching for something, I often find that the methods specified are bash specific. Even the syntax for the shell scripts is different for ...
3
votes
3answers
101 views

History of Bash globbing

Is there a historical reason why Bash "globbing" and regular expressions are not identical? For example, I believe that in Bash [1-2]* matches anything that starts with a 1 or a 2 followed by anything ...
1
vote
1answer
44 views

Awk that I am stuck on

I have a project I am working on for work. The script I am building initially takes two arguments: one is an unique Identifier and the other is for a log file (both strings). Now I have the first part ...
4
votes
0answers
53 views

Tracking my shell path in Emacs

Not a long time ago, I found the following precious snippet that allows Emacs to track my current directory on any ansi-term buffer. More specifically, if I cd <some/path> from within a ...
1
vote
3answers
418 views

Difference between ls -l and ll?

I'm relatively new to programming as a whole and some tutorials have been telling me to use ls -l to look at files in a directory and others have been saying ll. I know that ls is a short list, but ...
3
votes
1answer
97 views

Rename files with spaces in a BusyBox shell

I'm trying to rename some files on my Synology Diskstation via SSH. The available shell is the BusyBox built-in shell: BusyBox v1.16.1 (2013-04-16 20:13:10 CST) built-in shell (ash) The move ...
6
votes
2answers
348 views

Array in unix Bourne Shell

I am trying to implement array in Bourne shell (/bin/sh). I found that way to initialize array elements is: arr=(1 2 3) But it is encountering an error: syntax error at line 8: `arr=' unexpected ...
2
votes
1answer
48 views

History in the Almquist shell in the NetBSD

In NetBSD /bin/sh is a modified version of the Almquist shell. With the command fc -l it is possible to view the last 16 commands typed in the prompt in the current session and not the older ones. ...
4
votes
5answers
113 views

bash script [ x$1 = x ]

I am reading bash script I do not understand what is going there. #!/bin/sh [ x$1 = x ] What is going on the second line and what [ x$1 = x ] mean?
3
votes
4answers
78 views

Protected environment variables?

Are there names of environment variables that cannot be overwritten by the user/a call to setenv? As I understand from POSIX1.2008, any process may edit the environment block, but must avoid ...
1
vote
6answers
81 views

Is there a way to find out the number of lines from a command output?

I am trying to compare command outputs between two servers. I want to find out the number of lines from the output of commands such as ls -l. Is there a way to do so? So far I have not found anything. ...
3
votes
2answers
65 views

Gzip large amount of symlinked files

I have a folder containing a large amount of symlinked files. These files are each on the order of 10-11GB (fastq files to be specific). They come from a variety of source folders, but I made sure ...
4
votes
3answers
113 views

zsh's “echo SomeText >> **/filename” in other shells

I need to fill all files with a specific filename (recursively) with a text. In zsh this can be done with echo SomeText > **/TheFileName I search generic solutions for sh-compatible and/or tcsh ...
0
votes
1answer
117 views

How do I cat a command file?

I have the output of the crontab -l stored in a file (crontab_file) with no extension. But whenever I try to cat it, I get errors saying command not found for multiple line of the file. Here is the ...
2
votes
1answer
56 views

Mysql synonym drop and create

I am running into the issue that, when the script is run, the MySql section of it isn't working or is droping the synonym. Is there something else i need to put into the command to have it log into ...
5
votes
5answers
210 views

Serialize shell variable in bash or zsh

Is there any way to serialize a shell variable? Suppose I have a variable $VAR, and I want to be able to save it to a file or whatever, and then read it back later to get the same value back? Is ...
2
votes
1answer
33 views

stdout is empty

When a run the command: cellprofiler --get-batch-commands "/users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5" in the shell, I get an output: CellProfiler -c -r -b -p ...
3
votes
6answers
784 views

Make directory copies using find

I have a directory with a bunch of subdirectories in it. Thus /usr/local/src/ccl/ccl-1.8/x86-headers$ ls elf gl gmp gnome2 gtk2 jni libc Each of these directories has a further subdirectory C ...
4
votes
2answers
98 views

Execution order with multiple commands

I'm relatively new to Linux and I'm working on a CronTab for scheduled backups. I figured out how to do multiple sequential jobs with ; and &&, but I'm unsure how the dependency affects the ...
5
votes
3answers
633 views

Batch copy to multiple directories

I have about 9000 files in a directory and I want to mv them into 90 files in 100 directories by filename order, ignoring any remainder. In Copy multiple files from filename X to filename Y?, Caleb ...
28
votes
3answers
2k views

What does `{ { (exit 1); exit 1; }; }` mean?

I quoted the next code snippet from config.status generated by configure. if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 ...
2
votes
4answers
69 views

Get the latest directory (not the latest file)

My folder parent has the following content: A.Folder B.Folder C.File It has both folders and files inside. B.Folder is newer. Now I just want to get B.Folder, how could I achieve this? I tried ...
1
vote
1answer
54 views

Getting the parent path from a script

I have a bash script foocaller, which calls a ruby script foo: foocaller /path/to/foo Within foo, I want to get the path of foocaller. Following this suggestion, I put the following code to do ...
3
votes
3answers
81 views

Can't open shell after changing default shell

I changed my default shell to zsh from bash in Ubuntu. I used the steps explained in http://github.com/sorin-ionescu/prezto and ran chsh -s zsh. After this, I couldn't able to log in to any shell as ...
2
votes
1answer
43 views

How to move a window to a different workspace using its ID, in bash?

Currently I have successfully used wmctrl -r :SELECT: -t 2 but something like wmctrl -r -i 0x03e00003 -t 2 does not work. How should I write the command in order to select the window to be moved ...
-1
votes
1answer
28 views

Make an alias that does an alias command

I have to make an alias that will do the alias command. It has to "replace" the alias command and the user has to feel no difference..
5
votes
1answer
72 views

What are the difference between those four commands (fifo, process substitution, redirection…)

My goal is to create a simple echo server using nc and a single fifo. I'm not looking for the best way to do it, I'm merely trying to understand the semantics of the following commands (when does fork ...
2
votes
2answers
836 views

Pretty output in GHCI: no colours shown

Using this method to get a pretty GHCI colours, I am not getting any colours whatsoever. However, my terminal is a urxvt with 256 colours enabled and TERM is xterm-256color. Any idea what I could ...
2
votes
1answer
73 views

Why is my tar in a script behaving different than using tar manually

I'm writing a backup script for my email and cloud service. For simplicity, I only posted the mail-backup part here. Basically, I have a Host-Machine with some Virtual Boxes running in it. These ...
1
vote
1answer
52 views

Matching two files, line by line? [closed]

I have two files consisting of numbers. Now, I want to match the line of first file to all the line of second file and increasing the counter if the match is found. How to write the bash script for ...
11
votes
5answers
18k views

Move folder content up one level

I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
0
votes
0answers
27 views

Use FindBugs in Eclipse from terminal on Ubuntu

Is there any way I could use Findbugs from terminal to get all the bugs in my Java code and print it out to a text file? I want to write a script that goes through 100 java files ( this is already ...
2
votes
5answers
506 views

How to use the sed command to only show the first column and last column in a text file

I need some help to figure out how to use the sed command to only show the first column and last column in a text file. Here is what I have so far for column 1: cat logfile | sed 's/\|/ /'|awk ...
6
votes
3answers
163 views

Shell script to search files for identical text entries

Here's a nice teaser for a shell scripting guru: Take a directory with several text files. Can be a few up to ~1000. All files contain an identifier on a given line (always the same line). Identify ...
5
votes
3answers
991 views

Prompt user to login as root when running a shell script

The problem I am getting is, when I enter the command, su - root at the beginning of my shell script file, it prompts the user to enter the password and then does NOT continue with the rest of the ...
4
votes
2answers
465 views

How can I get the output and test the dig command?

when we type " dig +short www.example.com " command we get something like that: www.example.com. 192.168.1.1 192.168.1.2 192.168.1.3 I want to get the first address and test it if it is what I ...
1
vote
3answers
144 views

How to get a string between two special characters using Shell?

I want to get a string between two special characters. For example, /home/oracle/ggs/text.ext I want oracle/ggs in the above string. How can I do this using bash?
0
votes
2answers
91 views

How can I grep for broken HTML tags?

I want to grep through all my HTML files and see if I have any bad tags there, example <br> , <hr> and so on, that is the I want to see what tags are not closed in the HTML file. for ...
1
vote
1answer
61 views

upstart writing to syslog in a simple way

I have an upstart script that uses pre-start script exec >/dev/kmsg 2>&1 echo starting program # run my program here npm install node app.js end script to redirect output of a ...