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
45 views

Passing list of ignored directories to `tree` command [duplicate]

I'm writing a script in which I need to generate a tree of directories. How to pass to tree a variable with list of directories to ignore? And those directories are with spaces in name. I tried ...
-1
votes
0answers
32 views

not able to match the exact directory name [duplicate]

Issues in the below code : It should execute the loop when $a should exactly equal to the directory BE but the loop is executing for many names like BE_REP , BE_REPPP etc Pls loop into the issues. ...
1
vote
1answer
40 views

Recursively count occurrences of a word in identically named files in different directories

I've got several different directories that contain different versions of some files. I want to count a symbol in all versions of the same file. Here is an example of the hierarchy. directory ...
0
votes
2answers
25 views

Braces don't work when there is a single element

I am able to scp files based on their extensions as, scp sk@localhost:/home/sk/*.{txt,text} . But when I try to scp a single extension type, it fails, scp sk@localhost:/home/sk/*.{txt} . I was ...
1
vote
1answer
57 views

sh - Using Arguments in .profile functions

I want to use an argument in the function I created in my .profile file. I want to ask for input if no argument is given, otherwise set a variable to $1. When I check $1 to see if it is empty, I ...
0
votes
1answer
25 views

–mtune=arm920t”: command not found

When I run CC=”${CROSS_COMPILE}gcc –march=armv4t –mtune=arm920t” I get a –march=armv4t: command not found error, when i remove –march=armv4t and run: CC=”${CROSS_COMPILE}gcc –mtune=arm920t” i get ...
4
votes
2answers
244 views

New line in bash variables

I'm trying to store multiple lines in a bash variable, but it doesn't seem to work. For example, if I list /bin one file per line and store it in $LS, then I pass $LS as stdin to wc, it always ...
2
votes
2answers
52 views

Output distribution to a maximal number of columns

I have a bash script foo that provides me with many short lines of output. Think ls -1. To get a more compact presentation, I would like to distribute the output over multiple columns, like ls -C. I ...
0
votes
1answer
39 views

Bash if statement not working properly [closed]

I have a bash statement to test a command line argument. If the argument passed to the script is "clean", then the script removes all .o files. Otherwise, it builds a program. However, not matter what ...
0
votes
1answer
33 views

increment a value pulled from a file

I have a cron that I am writing that will repeat every hour, and I need a simple way to pass a counter from the last run to the next run. My plan was to add the number to a file at the end, and then ...
0
votes
0answers
26 views

Why does the Gnome desktop (nautilus) and the user's shell script conflict?

Why is that if the user's shell isn't defined to be /bin/bash but a custom bin/bash type script instead the graphical interface's desktop part will load slower or over vnc it won't load at all just ...
3
votes
3answers
143 views

Setting up a ssh-only jump box

I'm admining an AWS cluster, and am currently planning to run ssh access exclusively through a single jump box rather than dealing with public keys or LDAP authentication for ever-changing access ...
1
vote
1answer
65 views

Delete all files to which no corresponding file with another extension exists

My goal is to find a Linux command sequence, which deletes some files if a special condition is fulfilled: All files with the extensions .cut or .cut.bak in the current directory shall be removed, IF ...
1
vote
3answers
112 views

How to create a TCP listener?

Introduction: I have created a bash function that is able to check whether a port is available and increments it by 1 if false until a certain maximum port number. E.g., if port 500 is unavailable ...
0
votes
1answer
51 views

Select latest updated file from directory and send it via email

I want to select latest error(timestamp).log file from some directory and send it via email as attachment. What I am trying is: Filename: abc.sh echo 'An error occured' | mutt -s "Logs" -a ...
3
votes
2answers
132 views

Is there any Linux command to create a new file in a folder and auto create this folder if not exist? [duplicate]

I know this problem can solve by use combine mkdir and touch commands. But I want to know is there any other solution only use one command.
2
votes
1answer
45 views

How to read and do a min/max/avg from a NMEA stream

I have a weather station attached to my device spitting NMEA 0183 on /tty/USB0 I have alreeady sorted out how to parse the data and echo what I want in a script. What I need to do now is write the ...
0
votes
2answers
97 views

Explain the shell command: shift $(($optind - 1))

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
92 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 ...
-5
votes
1answer
47 views

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

What does command ps aux | sort -rk 3,3 | head -n 5 do ? Please explain each command .
1
vote
1answer
41 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
5answers
135 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
228 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
150 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
56 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 ...
1
vote
2answers
44 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
91 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
155 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
58 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
32 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
26 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
41 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
260 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?
11
votes
3answers
835 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
30 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
72 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
203 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
82 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
101 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
49 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
43 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
32 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 ...
21
votes
1answer
541 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?
5
votes
0answers
95 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
358 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
37 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 ...
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 ...
0
votes
0answers
8 views

lsudo /sbin/ldconfig -v showing Garbage text

RHEL 6.6 When performing "sudo /sbin/ldconfig -v" while trying to follow a different stackoverflow question related to: sudo /etc/init.d/nginx restart /usr/sbin/nginx: error while loading shared ...
2
votes
1answer
19 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
90 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 ...