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)

2
votes
1answer
30 views

Change Environment Path Variable Order

I am working on a CentOS box and trying to install a newer version of python. CentOS requires python 2.6.6 in order to run properly. To solve this I installed a second python (v 2.7.6) in ...
-2
votes
3answers
57 views

How to Show your main “shell” that you use.? in UNIX

How to Show your main “shell” that you use.? in UNIX is this command right ps -p$$ or if there is a different way? thank you
12
votes
6answers
394 views

Extraction of .gz files contained in a folder

I have a folder containing approximately 320116 .pdb.gz files. I want to uncompress them all. If I use gunzip *.gz it gives me an error i.e. argument list too long. The folder is about 2GB. Please ...
0
votes
1answer
2k views

Proper escaping of double quotations for curl post data?

I'm trying to test out a server, by sending it JSON data and reading the response. I need to POST data like {"item":"value with spaces"} but when I use curl I find that it sends the backslashes as ...
2
votes
3answers
27 views

get the apache document root using shell script

I am creating an RPM and in the pre stage, I want to determine apache's document root so I can copy the web application files there. First, I check if apache is installed. If apache is installed, ...
19
votes
5answers
6k views

Is there a program that can send me a notification e-mail when a process finishes?

I am a computational scientist, and I run a lot of lengthy calculations on Linux. Specifically, I run molecular dynamics (MD) simulations using the GROMACS package. These simulations can take days ...
1
vote
0answers
25 views

get the apache document root using shell script [duplicate]

I am creating an RPM and in the pre stage, I want to determine apache's document root so I can copy the web application files there. First, I check if apache is installed. If apache is installed, the ...
1
vote
6answers
229 views

Replace \n with blank in a file

I want to replace \n with blank Input file1 A\n D\n Output file2 I want A D I tried below commands but not able to replace please do needful. cat OUT | tr '\n' ' '
2
votes
4answers
108 views

How do I perform xargs grep on grep output that has spaces?

I'm searching for files based on a regular expression, and then I'm trying to search those files for content. So, for example, I have something like #Find all C++ files that match a certain pattern ...
0
votes
3answers
40 views

Replacing line with its line number

How can I replace the whole line with no matching pattern just with the number of the line? sed -i "${line}p c\ "$PWD" " file.txt
1
vote
0answers
14 views

How to move directories based on the output of rhash (CRC32 check of .sfv) with bash/perl?

My idea, is to move the CRC-check OK folders (albums) into a lets say "complete+CRC_OK" folder with a script once per day in cron. I would need to put the rhash command in a loop with number of ...
0
votes
2answers
36 views

how to split the string after and before the space in shell script?

I am having a variable which shows on echo like this $ echo $var 129 148 I have to take only 129 as output. How will I split 129 and 148?
0
votes
1answer
20 views

Rename and copy/move sets of similar named directories to another location

For a set of directories with similar names at different location, /foldX/dirA with sub-directories aa1 aa2 aa3 aa4 aa5 /foldZ/dirA with sub-directories aa1 aa2 aa3 /foldY/dirA with ...
-1
votes
0answers
41 views

What exactly is Ctrl + s? [duplicate]

In my terminal, if I press Ctrl+S it 'freezes' output, which can then be resumed with Ctrl+Q. What exactly happens here? What library/program supplies this functionality or at least says what ...
11
votes
2answers
3k views

How do I tell a script to wait for a process to start accepting requests on a port?

I need a command that will wait for a process to start accepting requests on a specific port. Is there something in linux that does that? while (checkAlive -host localhost -port 13000 == false) ...
5
votes
2answers
191 views

How to count duplicated last columns without removing them?

I have a file that contains 4 columns. I want to compare the last three columns and count how many times they occur without deleting any of the lines. I just want the count to be present in front of ...
1
vote
1answer
34 views

mv to file with

I ran the following mv command, apparently by mistake using backslashes by mistake instead of slashes. mv 2015-02-02_flyer_ppces.pdf ..\PPCES2015\2015-02-02_flyer_ppces.pdf The output is empty. ...
4
votes
2answers
198 views

BASH base conversion from decimal to hex

In Bash, how does one do base conversion from decimal to another base, especially hex. It seems easy to go the other way: $ echo $((16#55)) 85 With a web-search, I found a script that does the ...
19
votes
5answers
5k views

How can I create an alias for a git [action] command (which includes spaces)?

Most of my my aliases are of this form: alias p='pwd' I want to alias git commit so that it does git commit -v But trying to create an alias with a space gives an error: $ alias 'git commit'='git ...
0
votes
0answers
30 views

calling funtion of shell script file from java with an argument [closed]

I am trying to call a shell script file with one argument. But it is not working. What is the way to call this? And can we call a function of shell script file directly? From the servlet class I want ...
-1
votes
0answers
34 views

How can I encrypt specific words in a text file with a bash script? [closed]

I want to encrypt same words in a text file and I want to know how I can do it in bash. For example, if the file contains: The employee Kim Van, his registration number is ID721 he is work in the ...
2
votes
2answers
131 views

An error of variable type?

I've an error that I don't understand, it seems that that the problem is that my parameters into the shell are not of the same type as what they are in my SQL Database. For a better understanding: ...
8
votes
2answers
205 views

How bash treats “> >()”

While experimenting with output redirection and process substitution I stumbled upon the following command and its resulting output: me@elem:~$ echo foo > >(cat); echo bar bar me@elem:~$ ...
0
votes
3answers
122 views

How to ssh and execute a remote script within a local shell script?

I have a shell script which will kick off a series of jobs on a remote server. I can ssh into this server (but it does require a password!) and run the scripts manually, but there are certain steps ...
-2
votes
1answer
36 views

Append the content of a file to the value of a variable in ksh

Can we append the content of a file to the value of a variable in the Korn shell? How? /bin/ksh: $ B.11.31 Oct 1 2008 01:54:10 $ Version 11/16/88 blok.c $Date: 2008/08/20 12:15:51 $Revision: ...
0
votes
1answer
40 views

introduce a c script in a bash file [closed]

My problem is to recover data keyed in text file in bash. I seek the command that can perform this task and I used sed, awk and even cut but I have not succeeded. One friend of mine suggested to ...
0
votes
1answer
19 views

Why doesn't commons-daemon ./configure recognize $JAVA_HOME? [closed]

I'm trying to install a tomcat 7 server. I'm following these instructions from the tomcat 7 docs. I also set my JAVA_HOME variable in ~/bashrc as well as ~/.bash_profile and /etc/profile. I can do ...
0
votes
2answers
1k views

Why alias does not work in AIX (korn shell, .profile)?

I have these files in my home directory: drwxr-xr-x 3 meuser staff 256 Oct 12 13:11 . drwxr-xr-x 102 bin bin 4096 Sep 30 12:28 .. -rw------- 1 meuser staff ...
5
votes
3answers
199 views

Echoing stdin when running an ed(1) script

Given the following ed script, $ cat helloworld a hello world . ,n ,s,o,O,g ,n Q I would like to obtain somehow the interactive output $ ed a hello world . ,n 1 hello 2 world ,s,o,O,g ,n 1 ...
2
votes
2answers
153 views

How does one append a unix timestamp on a filename which is inside an argument?

To be more specific, I want the Unix timestamp to be appended to my file name: db:backup --database=mysql --destination=s3 --destinationPath=date+random.sql --compression=gzip However, this gives ...
4
votes
4answers
131 views

Insert new lines with missing values (NA)

I would like to insert new lines in text files if there are missing values. I have for example the following text file (A.txt), for which line 5 is missing. In addition, as the file should have 12 ...
1
vote
1answer
40 views

What is an alias really doing?

I'm looking for a way to check what an alias is really doing, without having to check the ${HOME}/.profile file, or whatever other file where you can define an alias. For example, if I run ll and I ...
2
votes
1answer
14 views

Making XMODIFIERS=@im=none emacs24 standard

I run emacs as XMODIFIERS=@im=none emacs24, otherwise some multi-keys for typing things like à won't work. How can I make this option permanent, so when I type emacs24, it runs as XMODIFIERS=@im=none ...
0
votes
2answers
50 views

Regular expression for excluding data within a certain range

I want to remove all the IP addresses which are of the format 10.20.30.* and whose last 3 digits fall in the range 0 to 200 and move all the remaining IPs to a new file. I've put the IP list to be ...
-4
votes
1answer
50 views

shell script for two numbers [closed]

Write a shell script to take two numbers from command line and show result of dividing small number with bigger number. Also note that it should not accept zero or negative number. If user enter ...
2
votes
1answer
121 views

Transform .csv into 3 columns and a row

Sample Input: id,Product1,Product2,Product3,Product4 1,0.1,0.3,0.8,0.7 2,0.6,0.7,0.5,0.9 I need output as : id,productname,product_val 1,Product1,0.1 1,Product2,0.3 1,Product3,0.8 1,Product4,0.7 ...
1
vote
0answers
46 views

How to move /usr folder and replace it with saved copy [duplicate]

If I made a backup of /usr with: # cp -r /usr /usrRESERVE1 how can i switch it back after some time: 1# mv usr usrRESERVE2 2# mv usrRESERVE1 usr second command will not work because mv is inside ...
1
vote
1answer
41 views

Ctrl+C process termination without Terminal killing

I started using Sublime Text 3 to compile my FreeFem scripts (interpretator PDEs package solver) under Ubuntu 14.04. To invoke the interpretator I customized the build system as follows "shell_cmd": ...
3
votes
2answers
68 views

save the number of files only in a specific folder

I'm using this script to save the number of files in a main folder, but it also counts the subfolders inside that main folder. nfiles=$(ls -1 /home/userA/mainfolder | wc -l) Any advice how I can ...
5
votes
4answers
8k views

What is the syntax of a complex condition in shell?

If want to express the following test in shell (sh) : if ( a == 1 && ( b == 1 || b == 2 )) { ... } So far, the best I have been able to write is this : if [[ $a -eq 1 ]]; then if [[ $b ...
3
votes
2answers
132 views

How do you stop a bash shell expansion?

I know some methods for stopping process. When I type: echo {1..999999} > filename.txt I can't stop it from running. I can stop other processes with Ctrl+C | Ctrl+D | Ctrl+\ and etc. But none ...
0
votes
0answers
21 views

Linux . Kali on android 4.2.2

hope this topic finds you well E: Unable to Locate Package thats the error that occur when i try to install any tool in kali on android I'm using Android with version 4.2.2 and kali is working well ...
5
votes
4answers
4k views

Bash, how to let some background processes run but wait for others?

I have (yet) another wait, &, && control flow question.. Say I have a script something like this where I want to do as much work at the same time as possible: # may take some hours ...
1
vote
2answers
33 views

Need special validation for shell script

I want to create a bash script which will have lot of options while executing. # script.sh --dry-run --user <parameter1> --pass <parameter2> I heard about getopt option but looks like ...
-1
votes
2answers
53 views

Difference between 'echo' and 'echo -e' [closed]

What is the difference between echo and echo -e? Which quotes should be used to execute a command after echo ie: echo "..." or echo '...'? Also what functions are available for the command echo?
0
votes
2answers
27 views

Why is wget still failing even after enclosing the URL with double quotes?

I enclose URLs I want to wget with "" since most of them have spaces, braces, etc. It usually works fine, but I can't get this URL to work: wget "http://xxxx/Sankarea - 6 - It`s Because I... Ran ...
1
vote
2answers
46 views

sh -c: Unterminated quoted string error [duplicate]

I've spent hours trying to understand the following error. My Script CMD="sh -c 'echo \"a\"'" $CMD Error: "a"': 1: "a"': Syntax error: Unterminated quoted string of course when I do echo $CMD ...
1
vote
2answers
274 views

How to put $@ in quotes?

My bash script looks like this: #!/bin/bash grep -r --color=always $@ . | nolong The file is saved in /usr/bin/findstr Everything's ok when I run this: findstr hello But when I run this: ...
1
vote
1answer
35 views

Saving colored output regardless of the source

How can I save colored output to a file regardless of the source when the sources turn coloring off if they detect their stdout isn't a terminal?
1
vote
1answer
21 views

zwrite handling of “@” symbol

I've been using zwrite to create simple message popups in AIX, and it handles @ symbols weirdly, even when they're strong quoted. I'm running these commands in ksh. As an example, echo '1 @ 2 @@ 3 ...