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)

0
votes
0answers
17 views

terminal valid path doesn't exist

I am having an odd issue where a path I generate from an HTTP POST does not register as valid, even though it clearly is. For example: This generated path ...
1
vote
0answers
43 views

Load a background image or set the background color if Konsole/Shell is running SSH

I want to set my laptop to load an image in the shell's background or set the background color to red if I'm connected via SSH. How can this be done? With a bash function in .bashrc? I have: Set the ...
1
vote
4answers
155 views

why do we not need export here?

$ IFS=";" $ read first second i am;a_i b c $ echo $first i am $ echo $second a_i b c $ echo $IFS Am I right that read first second is a subprocess of the current shell process? If yes, why don't ...
1
vote
1answer
32 views

Can I start a background process with a specific working directory?

Say I have this structure /masterscript /a/script1 /a/b/script2 In masterscript I spawn the other scripts as background processes: "/a/script1" & "/a/b/script2" & The problem is that ...
0
votes
1answer
40 views

Running shell script on cluster in parralel

I thought dsh(Distributed Shel) will be a good option but when i ran my shell script across my nodes, I didnt get expected output, dsh -aM -c bash /home/cloudera/bash_script.sh server2@x.x.x.110: ...
2
votes
1answer
18 views

How to sort files based on the json property value inside the file?

I've downloaded list of videos via youtube-dl and each file has corresponding .json file containing certain properties. So I would like to sort the files based on the selected json property which is ...
1
vote
0answers
48 views

How to start a process chain from the shell

Is it possible and if so how do I: Start a /bin/bash process that is not bound to a terminal from a terminal? Hence, a shell process that shows up in the process tree as init -- bash. (Shells ...
0
votes
1answer
8 views

How to automate ktutil to immediately list keytab entries?

I use MIT ktutil a lot on Linux and I am fed up using the following sequence, even if command shortcuts and file name completion are here to help: ktutil rkt my.keytab l Isn't there a way to get ...
6
votes
2answers
250 views

Why does source give an error “cannot execute binary file”

I have small file that does initialize a tmux session and then creates some windows. After some debugging and tweaking things worked fine until I renamed the text file (with the tmux commands) from ...
6
votes
2answers
146 views

Bash string concatenation used to build parameter list

Given this piece of bash: PARMS='-rvu' PARMS+=" --delete --exclude='.git'" echo $PARMS rsync ${PARMS} . ${TARGET} The echo shows the PARMS string as expected, no error is displayed, but rsync ...
1
vote
2answers
43 views

Apply given rsync exclude patterns on given directory

I have a setup where I use rsync to mirror some source directory to a (remote) destination except for some files and locations defined witch rsync exclude patterns: # Useless files - thumbs.db - *.~ ...
1
vote
2answers
79 views

I want to suppress “no access to tty” error message?

I have a bash script where I use ssh to connect to another server and run some commands there. I found some sites that the error (Warning: no access to tty (Bad file descriptor). Thus no job control ...
8
votes
1answer
143 views

How to “correctly” start an application from a shell

I find it hard to phrase the question precisely but I will give my best. I use dwm as my default window manager and dmenu as my application launcher. I hardly use GUI applications aside from my ...
2
votes
0answers
51 views

How can you get the current terminal line (the one that is still editable by the user)?

I need a way to use the current line which the users typed into as variable for a shell function. my current code, which can be called by ctrl+r zle -N search bindkey "^R" search search () { read ...
1
vote
2answers
36 views

Passing print pattern as a variable to awk

I am trying to use awk to print variables from various columns in a line delimited by , .The columns and pattern which I want to print is stored in another variable b. The pattern a and print patter ...
1
vote
1answer
115 views

Pattern replacement

Please can anyone explain to me in brief the syntax of this command. Explanation in terms of how actually this command is written significance of each and every character used. I know the output of ...
0
votes
2answers
90 views

Login by ssh , exec one command and i don't want to quit the bash

I want to change PS1 when i ssh another centos strshell = 'PS1="remote!"' os.system("ssh -i %s -l%s -p%s %s %s"%(SSH_KEY,SSH_USER,SSH_PORT,des,strshell)) ssh quit automatically. I want to ...
1
vote
2answers
61 views

Confusions mitigation while working similar environments in multiple servers

I often have to open multiple ssh sell terminals of remote servers together., eg. Dev and test. These paths and applications are exactly similar. And I am often confused if I run a particular command ...
2
votes
2answers
43 views

How do you get a count of all file extensions on a hard drive using the gnu+linux terminal?

On windows I have a program that can count all the files on a hard drive and the output shows a list of file extensions and a number (which showed how many files on the drive were for example are ...
5
votes
2answers
435 views

Is there any way to read lines from command output?

I have a pre process command to output a file ./preprocess.sh > preprocessed_file and the preprocessed_file will be used like this while read line do ./research.sh $line & done < ...
-2
votes
0answers
16 views

Explain a tsums command line

In putty, I am blindly writing codes as below, cat >! lot tsums @lot -format=lot,machine_id > ! MCID what is the meaning of these 2 lines?
2
votes
3answers
139 views

Saving individual output lines into variables

I'm using find -mtime -2 to find files modified in the past 24 hours or less. The output looks like this. /home/user/logs/file-2014-08-22.log /home/user/logs/file-2014-08-23.log I need to save the ...
2
votes
1answer
151 views

Syntax error near unexpected token `('

When I use below code in SSH terminal for CentOS it works fine: paste <(printf "%s\n" "TOP") But if I place the same line code in a shell script (test.sh) and run shell script from terminal, it ...
-2
votes
0answers
29 views

How do you match an arbitrary ratio of words of a certain length(such as one out of two words of at least 4 chars) with a regular expression?

Considering formatted text and using shell utilities, how would you match: All numerical strings and; For each line, for words containing 4 characters or more (à la strings) n word(s) out of every ...
2
votes
1answer
188 views

Running sh script: «Permission denied» despite the executable bit and root rights

I installed Debian in VirtualBox (for various experiments which usually broke my system) and tried to launch the VirtualBox guest addon script. I logged in as root and tried to launch autorun.sh, but ...
18
votes
4answers
751 views

Why doesn't the tilde (~) expand inside double quotes?

According to this answer and my own understanding, the tilde expands to the home directory: ➜ ~ echo ~ /home/braiam Now, whenever I want the shell expansion to work, i. e. using variable names ...
3
votes
4answers
148 views

gunzip a folder with many files

I have a folder with 36,348 files gz files. I want to unzip all of them. Running: gunzip ./* results in -bash: /usr/bin/gunzip: Argument list too long Whats the easiest way to get around ...
2
votes
1answer
18 views

ionCube shell script gives error

I have this shell script to install ionCube loader: if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi echo "Welcome to this script to install the ionCube loader on CentOS!" cd ...
5
votes
1answer
22 views

Upstart and bash function names containing “-”

I inherited some bash scripts where the author used "-" in the function names instead of the more normal "_" e.g.: function a-b { ... } Ugly but legal in bash. Problem is I sourced this inside an ...
2
votes
1answer
18 views

Comparison of columns in two files and appending the first file

I need a help on this :- I have a file : emp.txt 21356 suresh 12/12/2012 23511 ramesh 11/06/2011 31456 biswajit 09/08/2013 53134 archan 06/02/2009 first field:- employee id, 2nd field is name and ...
6
votes
6answers
221 views

Obtain values of a section of a file

I have a configuration file in the following format. <Title> [part1] A.File = a A.Val = val1 B.File = a B.Val = val1 [part2] A.File = a1 A.Val = val2 B.File = a B.Val = val1 ...
1
vote
2answers
36 views

How do I find a files directory?

I am looking for a specific file in OS/X. I can see the file by using: ls -alR | grep "mkmf.*" This shows my that the file exists. How do I find what directory the file is located. Many thanks ...
13
votes
0answers
756 views

What does “mv *” do? [duplicate]

I just gave this command by accident mv * while I was in a directory, needless to say that the content of my dir is gone and I have almost no hope to recover it, luckily it wasn't something ...
2
votes
1answer
36 views

Read target of symlink and increment target by one

I have a folder structure that looks like this /some/folder/1 /some/folder/2 ... and a symlink current that links to one of the folders. Is it possible and when how to read the target of the link, ...
1
vote
3answers
47 views

How to send a output of unix command from one server to another server?

How to redirect the output of a unix command from one server to another server. I should be able to send the unix command's output from server-1. Then I should be able to receive the output in ...
4
votes
2answers
64 views

How do I cancel/replace one element of running `cmd1 && cmd2 && cmd3 && …` chain?

$ command1 && command2 && command3 Running command1 ... Running command2 ...^Z [1]+ Stopped $ fg && command4 && wrong_command5 && command6 Running command3 ...
0
votes
2answers
34 views

How to set cron job for system

I'm really new on Linux and have no any previous experience on it. And I opened this account to ask this question. I need to install a cron job I've followed the short guide here. Well, I think it ...
3
votes
4answers
157 views

Redirect and pipe output

rpm -qa > file | wc -l returns 0. What am I doing wrong? I think it is clear what my goal is, but it isn't working. Is this a job for xargs or tee?
1
vote
3answers
47 views

How to handle backspace while reading?

How do I handle the backspaces entered, it shows ^? if tried & how read counts the characters, as in 12^?3 already 5 characters were complete(though all of them were not actual input), but after ...
1
vote
3answers
43 views

bash/shell pathname expansion for mkdir, touch etc?

So doing something like this in bash and most other shells won't work to create multiple subdirectories or files within subdirectories... mkdir */test touch */hello.txt There are of course many ...
1
vote
2answers
37 views

Why asterisk in command result in for loop is expanding?

I want to write a script that will run git diff --name-status master..<BRANCH> but when I run this: for i in $(git branch | grep -v master); do echo $i; done I get echo one directory ...
3
votes
6answers
73 views

Use a shell not installed on remote machine

Given the scenario: Remote machine: SSH server; user does not have admin privileges; Local machine: SSH client; user has admin privileges. If user, logging in to remote from local, wishes to ...
8
votes
3answers
649 views

What is the usage of $& in bash?

I was looking into special parameters in bash. I am curious to know what is $& and how it is different from $_. I see the following output when running the commands but could not locate the ...
0
votes
1answer
44 views

`command` vs `type` - Locate program file in user's PATH [duplicate]

I need locate program file in user's PATH. I found few solution, the best are command and type. Which is better, faster, UNIX-like way and why? command -v <application> type -p ...
0
votes
1answer
35 views

Quote escaping struggle with grep and sed

I'm writing a bash script to extract data from html tags and I found this command in another thread : grep -o '<tr>.*</tr>' HTMLFILE | sed 's/\(<tr>\|<\/tr>\)//g' > NEWFILE, ...
1
vote
0answers
31 views

Edit a command? [duplicate]

I'm using many basic commands of unix/linux. In Mac OS X Mavericks, I type cat for a file, but output was faulty. In example, content of the file named bar: foo bar Then: ...
3
votes
1answer
164 views

How does the colon sign and dollar question mark combine in sh?

The "colon sign" and the "dollar question mark" can be combined to check if a sh script does have an argument and assigns it directly to a variable of interest: cmd=${1:? "Usage: $0 ...
3
votes
1answer
24 views

X commands do not start from my at job

I'm learning about Linux scheduling commands including at, cron, sleep etc. I'm trying to launch gedit after x minutes via the at command. This is what I have: kedar@i5 ~ $ at now + 1 minute at now + ...
4
votes
3answers
95 views

Passing arguments from one command into the next

I'm trying to write a script to unify two separate commands I run by hand into a single bash script I can then cron. The first command is a simple find on files with a certain name and size find ...
1
vote
2answers
98 views

Rename a file dynamically containing spaces [duplicate]

I want to rename a file dynamically based on data which contains spaces Name="Abc DEF" Name1="GHI JKL" mv /sample/pdf/noriginalName.pdf /sample/outputPdf/${NAME}${Name1}".pdf" But it gives me an ...