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
2answers
34 views

Linux Command Syntax not getting what is it

I am not a Linux guy but stuck in some Script which I have to read for my Project. So can anyone can help me what this command is doing? shift $(($optind - 1))?
0
votes
4answers
89 views

The first Line of Scripting [duplicate]

what does #!/bin/bash at the 1st line mean ? Is it just a comment and ignored by the shell like all other comments in program OR Only this line is interpreted by the interpreter and all the other ...
-4
votes
1answer
40 views

What does ps aux | sort -rk 3,3 | head -n 5 meant? [on hold]

What does command ps aux | sort -rk 3,3 | head -n 5 do ? Please explain each command .
1
vote
1answer
32 views

Linux shell: pick columns from a variable length csv file

I have two csv files, which share a column that is unique to each row in each file, like an ID. The files don't have a header. The file_2 has variable length columns e.g. 1,2,3 4,5,6,7,8 I joined ...
1
vote
1answer
30 views

Can see file in /usr/local/bin with ls, but attempting to run it yields file not found?

I'm on OS X, but since this is terminal work I figured this was the best place to ask. I'm trying to get Sublime Text to work at the command line via subl and having no luck. I ran ln -s <location ...
2
votes
2answers
55 views

Can't login to server with SSH because of a script in /etc/profile.d exiting with exit status 1

so I have this problem, I can't login to my server with SSH. See: ssh -v myuser@myserver debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug1: Requesting ...
8
votes
1answer
201 views

Shell namespaces

Is there a way to source a shell script into a namespace, preferably a bash shell script but I would look into other shells if they had this feature and bash didn't. What I mean by that is, e.g., ...
4
votes
1answer
144 views

Making the current directory as if it were where an absolute path starts

I'm wondering if there is an application that makes it so that commands after it operate in an environment that treats the working directory as if it were the top-most one, and there is absolutely no ...
1
vote
2answers
46 views

Exporting a function from .profile/.bashrc

What am I doing wrong...? It's fine if I do this on the command line and then call it but not when I load it from .profile. Linux Mint Qiana, Bash 4.*, if it matters. function android() { command ...
0
votes
2answers
19 views

Working with exporting PATH CentOS strange behaviour

I am trying to modify the PATH variable in two different scripts located in /etc/profile.d/ /etc/profile.d/php.sh #!/bin/sh PATH=$PATH:/usr/local/php/bin export PATH /etc/profile.d/mysql.sh ...
4
votes
1answer
57 views

using pipe to run command in background

I was reading this question on rpi and noticed an interesting line that got me thinking: mkfifo tcp.stream nc -l -p 1234 > tcp.stream | omxplayer --live tcp.stream Notice the io redirection. ...
5
votes
1answer
95 views

Logging bash output to a file

I'm trying to build vlc which is rather complicated and dependent on having the right packages installed, and keeps choking on errors. To trace all my steps I wish to output what I'm doing to a ...
3
votes
1answer
40 views

Parameter expansion in variable assigned with a wildcard

I have two files in my current folder (MA502) whose names are - MA502_TAAGGCGA-TCGCAGG_L001_R1_001.at.fastq MA502_TAAGGCGA-TCGCAGG_L001_R2_001.at.fastq I have many such folders - ex MA503, MA504 ...
1
vote
0answers
23 views

csh: How to save the shell environment (env, current dir, shell history) in a file and set it on another shell?

I start interactive terminal using farm (LSF). These terminals get opened on some random host and get closed automatically after 15 days. I want to save the current shell environment (env, current ...
0
votes
0answers
14 views

Getting CRC mismatch warnings in gdb on cygwin

When I run any program under gdb in cygwin shell I get following warnings... warning: the debug information found in "/usr/lib/debug//usr/bin/cyggcc_s-seh-1.dll.dbg" does not match ...
2
votes
1answer
30 views

View remote value of $PATH inside shell script

When executing this bash script, it only shows my local path. ssh ${REMOTE_HOST} 'bash -s' <<EOL set -e source ~/.profile echo $PATH # Commands here don't work because $PATH is ...
2
votes
3answers
235 views

copy all files that have no extension

We can copy some file by extensions like this: cp *.txt ../new/ but how can I copy all files that have no extension?
10
votes
3answers
775 views

How to understand “cat > file_name << blah” command?

In following command cat takes the content of here-doc and redirects it to file named conf: cat > conf << EOF var1="cat" var2="dog" var3="hamster" EOF How to understand the order of ...
0
votes
1answer
27 views

Running multiple commands at the same time

I want to run two commands on terminal on my virtual machine at the same time. I have this as of now: sudo ptpd -c -g -b eth1 -h -D; sudo tcpdump -nni eth1 -e icmp[icmptype] == 8 -w capmasv6.pcap ...
2
votes
2answers
65 views

Difference of using () and $() to execute a series of commands

I am currently trying to make a script that creates bytes that will be piped as input to netcat. Here is the idea of the script: (perl -e "print \"$BYTES\x00\"; cat file; perl -e "print \"More ...
4
votes
3answers
169 views

How to print control characters with escape sequences?

I have defined the color red using tput red=$(tput setaf 1) to colorize warnings in my program. This works fine: printf '%sfail\n' "$red" # prints 'fail' in red But on one occasion I would like ...
1
vote
3answers
76 views

For loop for a set of variables

I would like to run a for loop for a set of variables which I incorrectly denote as {A,B}. Following that my script looks like: #!/bin/sh for {A,B} in {1,2} {3,4} {5,6} {7,8} do echo A=$A B=$B ...
3
votes
3answers
91 views

How to kill this process in bash

I am trying to interface my homemade Raspberry Pi-powered arcade machine with a coin acceptor, and for that I: use a shell script (named gameplay) which starts the game emulator (MAME) when a coin ...
-2
votes
1answer
37 views

Execute bash snippets directly in shell? [closed]

Is there any way to execute small bash snippets in the shell? If you don't want to edit a file again and again and test it by executing it again and again (in fact by jumping forth and back between ...
2
votes
3answers
40 views

Find a directory which contains all the files in my list

I have moved a file, which makes a reference to four other files with the same parent directory. And now I am stock trying to figure out which parent directory that is since there a number of files ...
0
votes
2answers
30 views

How to find file that has read permissions from root directory?

I am trying to find files with read permissions from root directory and save them under /home/student/abc direcory: find / -type f -perm a+r -exec cp /home/student/abc {} + but it shows me the ...
18
votes
1answer
425 views

What does it mean to have a minus sign as the first character of a command in htop output?

In htop, or other commands that show process status, all bash processes have in the command column /bin/bash but one process has in the command column -bash What does it mean?
4
votes
0answers
88 views

Peculiar Solaris integer comparison behaviour

This one caught me unawares! We have a Solaris machine (version: SunOS 5.8) hosting a pivotal script/process which has been running for many years without complaint. We recently had cause to have a ...
4
votes
3answers
276 views

Exiting a shell script with nested loops

I have a shell script with nested loops and just found out that "exit" doesn't really exit the script, but only the current loop. Is there another way to completely exit the script on a certain error ...
2
votes
1answer
29 views

Start sh in a specified directory from inittab

I am currently working on an embedded Linux system. For it to be similar to our other products I need to have it start a shell in a specified directory on boot, accessible using the serial port. For ...
-4
votes
0answers
17 views

create crontab job scheduling every day 10:44 AM in shell scripting [closed]

crontab job scheduling every day 10:44 AM in shell scripting
2
votes
2answers
61 views

What's the appropriate way to do “mv ./* ./subdirdir/”? [duplicate]

Under the current directory I have a number of files, and one directory. I would like to move all files to the sub directory: mv ./* subdir/ cannot move ./subdir to a subdirectory of itself... The ...
-5
votes
0answers
19 views

terminate when user type -1 [closed]

#!/usr/bin/env bash # Above, get the path to BASH from the envvironment. # Below, you could just set the total mileage here. total_mileage=0 # Below, start from zero and count up for the three ...
2
votes
1answer
16 views

Running make for LFS complains about [ and about missing gawk

I'm having a strange error when I'm trying to start the make process for LFS using the LiveCD SVN Trunk. When I go to run make it gives me; $ make /bin/sh: 1: [: -ne: unexpected operator -e Missing ...
-1
votes
2answers
43 views

shell script not running using crontab

This is my script mboxutil -l > n.txt sed 's/^.*user//' n.txt > n1.txt cat n1.txt | sed 's/^.//' > n2.txt sed 's/\/.*//' n2.txt > dss_list.txt rm -f n.txt rm -f n1.txt rm -f n2.txt sed ...
6
votes
3answers
275 views

Should I use a slash at the end of path variables in shell script or not? [closed]

Today when writing my shell script. A question suddenly comes to my mind. Since cd /target_dir and cd /target_dir/ both works. Should I add a slash at the end of my path variables in a shell script? ...
1
vote
1answer
46 views

Batch move all files from subdirectories to parent directory, but files have same name

I have many files in sub-directories that I would like to have all moved to the parent directory. Ex: 20150530XXXX/1.jpg 20150530XXXX/2.jpg 20150530XXXX/3.jpg 20150530XXXX/4.jpg 20150531XXXX/1.jpg ...
4
votes
3answers
160 views

awk and newlines in the input data

I want to find files in a directory and identify by their mimetype, not by the extension of the files. I'am using this command to determine the mime type: % find . -type f -print0 | xargs -0 -I{} ...
6
votes
4answers
818 views

Add a newline into a filename with `mv`

It's a serious question. I test some awk scripts and I need files with a newline in their names. Is it possible to add a newline into a filename with mv? I now, I can do this with touch: touch ...
13
votes
1answer
177 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
0
votes
1answer
46 views

Issue a command in each directory

I have 3 directories: dir1 contains two subdirs. In every subdir there is a slackbuild. I want to build all slackbuilds, staying in the parent directory. I have tried (cd *;sh *ld) But it only ...
0
votes
2answers
51 views

How do you search ! in man sed?

You cannot search ! directly because it puts process behind. For instance, you cannot search ! in sed man. How can you search ! in man?
2
votes
1answer
66 views

Convert IP Address to Coordinates using database

I have a file which contains IP and I wanted to compare it to Coordinates using a local database (instead of API). I tried following a process and break down to pieces and created scripts referring ...
0
votes
1answer
44 views

Practical usage of “shift” shell builtin command?

I checked the /usr/bin/ssh-copy-id(part of openssh-client package at least under Debian) shell-script and it contains following if-statement: if [ "-i" = "$1" ]; then shift # check if we have 2 ...
2
votes
2answers
52 views

ssh command with quotes

I have an odd error that I have been unable to find anything on this. I wanted to change the user comment with the following command. $ sudo usermod -c "New Comment" user This will work while ...
5
votes
6answers
500 views

How do I check if a variable exists in bash?

I need to check a variable's existence in an if statement. Something to the effect of: if [ -v $somevar ] then echo "Variable somevar exists!" else echo "Variable somevar does not exist!" ...
1
vote
1answer
43 views

Move files from multiple directories to another system

Let's suppose I have a folders in the source system: AB1, AB2, AB3. And I have the same folder names AB1, AB2, AB3 in the destination system. I want to move AB1 files to AB1 and AB2 files AB2 and ...
1
vote
2answers
53 views

How do i search for certain sections of a file and then extract only relevant information within that section?

So I have a text file that is a server report and has about 1000 lines of information in it. I'm trying to write a script that can search the report for only certain pieces of information I'm looking ...
2
votes
3answers
158 views
+100

locate alias with find

On small systems where there is no locate installed, How would an alias look like that gets the same result as locate? I can imagine find can produce the same output so an alias could look like ...
-3
votes
2answers
41 views

Transform text records using only a “for” loop

I have an input file that is text, consisting of lines that look like: 352|C|PAID|7036|VOICE|01-FEB-12 I need to split each line into fields at the | (vertical bar) characters and output each field ...