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

meaning of [$? -ne '0']. (shell script)

could anyone tell me what the following command means? I'm reading a shell script and studying what it does. But at the end of the script, the following commands appeared. I have no idea what it ...
1
vote
0answers
10 views

Comparing original & backup folder, then deleting non-existing files

I'm using Raspbian jessie (ubuntu). I made a .sh that makes a backup .img of everything (excluding mnt, tmp, run, dev, boot, etc.) and let this run once a week with crontab. It checks for modified ...
0
votes
1answer
26 views

Listing files with a certain extension

I'm suppose to write a command that would list all files that end in .tx with an optional t at the end. So far all I got is listing the files that end in .tx which is: ls *.tx Now my problem is ...
0
votes
0answers
12 views

My terminal is giving unformatted results (output) after upgrading to Ubuntu 15.10

Whenever I run g++ to compile any C++ code, My terminal is showing some weird output. Even when I do like man ls And this happened from the moment that I upgraded from Ubuntu 15.04 to Ubuntu ...
1
vote
0answers
17 views

Getting Busybox Cron to work on Qemu ARM VM

I created a .sh script, then tried crontab -e and entered * * * * * /etc/cronscript.sh, then tried to start it by typing crond. It looks like its trying to do something once per minute, but not my ...
3
votes
2answers
26 views

Run in background but not discarding the output

I use a Git hosting. So I often run git push. I want to run git push in background, in order that me not to wait when it finishes but do other tasks in my terminal. But I don't want to run git push ...
0
votes
0answers
20 views

meaning of !(something) in shell [duplicate]

While searching for a way to move all files in a dir to one of its sub-folders, i came across mv !(something) something which should do the job - but only in bash. However i could not find why. in ...
1
vote
1answer
25 views

How to get file descriptor number of a output and how to redirect all of them at once

Lets take this command for example $ time ssh ec2 ls www apps real 0m0.554s user 0m0.004s sys 0m0.000s $ time ssh ec2 ls 1>/dev/null real 0m0.554s user 0m0.004s sys 0m0.000s ...
-1
votes
2answers
37 views

how to login a user using shell script [on hold]

In my computer i have two user(tiger,jenk) now i want to create a shell script for login user "jenk" from user "tiger" i m try this code [tiger@pagaltiger mytask]$ echo -e "IncorrectPassword\n" | ...
0
votes
1answer
33 views

Only send email if disk usages exceeds 80%

My script is: abc=$(df -h | sed s/%//g | awk '{ if($5 > 80) print "Alert "$0;}' | awk '{print $2,$6}') \ && echo -e "Dear All, \n\n$abc\n\nABC" \ | mailx -s "Disk partition" ...
0
votes
2answers
35 views

How do I permanently remove an Alias from my Shell

When I was not near my computer some guy got it and set an Alias for ls in my root folder. He set it to 'yes NeverGonnaGiveYouUp'. So now when im in my root folder and type ls I get an infinite loop ...
1
vote
3answers
33 views

Run a command over directories with name recursively

I have the following directory structure in AIX. codeRepo/REPO1/AREA1/objects codeRepo/REPO1/AREA2/SUBAREA1/objects codeRepo/REPO1/AREA2/SUBAREA2/objects From codeRepo I want to run chown myUser * ...
0
votes
3answers
65 views

To calculate average by taking command line argument

The task is that if input numbers: 4 1 2 9 8 Output=(sum of all except first_number_in_series)/first_number in series Then output average should be 1+2+9+8/(first_number_in series)=20/4=5 I have ...
0
votes
1answer
28 views

Kill command also kills other process

I have a very simple script, let's call it foo.sh. It's this: #!/bin/sh sxhkd & panel & where panel is a script (I won't post it here because it's very long and I don't think it would be ...
0
votes
2answers
35 views

Which location does shell assign normal variable?

As you know, bash shell itself is also process. If I use command export a=c, then shell dynamically allocates variable a into location where environment variables are reside.(This environment section ...
1
vote
1answer
43 views

Combining strings command and grep: how to limit results to null-terminated strings

I have a feeling that it is strings which is thwarting my efforts here. The binary files I want to use strings on unfortunately yield several matches per file, even though it is a 100% rule that ...
2
votes
1answer
17 views

Get current memory usage of a tmux session

As the title says. I need a way to the used memory of a current tmux session. I am not sure if that is even possible. I am using tmux to start multiple minecraft servers I'd like to know each servers ...
3
votes
3answers
33 views

Can the Bash shell “Ignore” Excess copy-paste text?

Say, I have a "Quick&Dirty" Perl script in a gui text editor, and I start the Perl interpreter in a terminal window which is running Bash. I can copy-paste the Perl script to the terminal & ...
1
vote
2answers
19 views

bash adding a filename to an alias command [duplicate]

I have an alias to a ffmpeg command to start recording a session like this: alias sreq='ffmpeg -f x11grab -r 24 -s 1024x768 -i :0.0 -qp 0 -c:v libx264 -preset veryslow' I can just type sreq ...
-3
votes
0answers
16 views

Removing intermediate line breaks in muliple columns except the last new line character [on hold]

Suppose If I have the data like this Col1|Col2|Col3 <br\> 123|abc\n<br\> xyz\n<br\> |abc\n<br\> def\n<br\> other rows<br\> <br\> In the above newline ...
0
votes
0answers
31 views

How to get curl progress bar in terminal?

I'm using curl to upload files from a bash shell. I know there's the option --progress-bar which is supposed to give an upload progress indicator, but no matter what, I can't get it to show. I do ...
0
votes
1answer
37 views

Unexpected end of file in .bash_profile

When I do source ~/.bash_profile I get this "line 14 syntax error: unexpected end of file" error, I tried to delete the last line for no avail. Thanks # Get the aliases and functions if [ -f ...
0
votes
2answers
98 views

Why does the cd command handle STDIN different than other commands?

Commands like cd cannot have output piped to them in order to change directories--they require command-line arguments. Why does the cd command (and those similar to it, such as mv, cp, & rm) not ...
0
votes
1answer
41 views

Kill a running shell script, and kill all process running within it

I have a shell script running in the background, which runs 5 different jobs. When I run the shell script all 5 jobs start running in order. When I kill this shell, whichever process is running, will ...
1
vote
3answers
30 views

How do I organize and cut this portion of a directory into a file?

I'm new to unix and I'm not sure how to name my title but my main objective is to copy the contents of a directory and send it to a file. Then cut out the directory location to just have the name. ...
1
vote
0answers
50 views

Some commands are no longer responding?

I have a Debian based distribution & lately a problem has been encountered when trying to execute the gcc or man command's (And probably other commands I haven't found yet). When I type them in ...
1
vote
1answer
26 views

Can Bash tell an interactive SSH session from an in-line SSH session?

I have a Bash script that needs to be run from an interactive prompt, due to environment variables and configuration that only seems to be read when actually logged into a session. Examples below: ...
2
votes
1answer
55 views

Something confusing about “su -” and “su” [duplicate]

I am studying the Linux command line. But the book which I'm reading says that su -l(-) username is starting a new shell session and loading the environment of the user I want to change to, but su ...
13
votes
5answers
306 views

How can I find the first missing directory in a long path?

Imagine I have a path that doesn't exist: $ ls /foo/bar/baz/hello/world ls: cannot access /foo/bar/baz/hello/world: No such file or directory But let's say /foo/bar does exist. Is there a quick way ...
3
votes
3answers
323 views

How to sleep until a given date & time?

I want to write a shell where given a date (day-hour-min) e.g. 10:00 AM Sun 2:30 PM Mon ... It sleeps until that exact date & time. I thought one way of doing it is, I could get the current ...
1
vote
1answer
46 views

bash - queue subshells

function _abc { : 1 min task : _check & } function _check { wait for the previous calls of _check to complete : 15 mins task : } function abc loops depending on number of tasks. It is ...
4
votes
1answer
55 views

Are there non-interactive login shells?

I know what the difference between interactive/non-interactive and login/non-login shells are, but it seems like in practice there's never going to be a non-interactive login shell unless you have ...
1
vote
1answer
43 views

generate file names in loop [closed]

DISCLAIMER: I am using Mac OSX. The bash script is in a different directory from the files that require processing. From here my struggle begins… HELP 1: I have multiple files each housed in a ...
1
vote
2answers
51 views

Unable to run a process on background

I need help with a Solaris system. I have used the following command to run the cp.sh script in the background. nohup sh cp.sh < /dev/null & > /dev/null & output: Invalid null ...
-1
votes
2answers
21 views

shell command wrapper for socat

I have used the command socat - foo The text I type is sent directly to address foo. Is there some general-purpose wrapper for stdin (along the lines of ! from ed) that lets one parse a shell ...
1
vote
1answer
25 views

Cron Job Hourly Except Certain Time Frame on Friday

I want my cron job to run every hour, every day except Friday when I don't want it to run at all between the hours of 2am-9am (but hourly outside of this timeframe). Ideally, I'd like to have this in ...
0
votes
0answers
37 views

Bash script is not executing after reboot command Ubuntu 14.04

I've tried using a /etc/init.d/ script, an upstart script, crontab, etc. None of the above are causing the script to execute on boot. The service I am attempting to automatically start on boot is ...
0
votes
2answers
31 views

How to seperate executable calls as different functions in shell script?

This is what I would like to achieve. #!/bin/bash function startBasics() { gnome-terminal -e "sth" & gnome-terminal --tab -e "sth_else" & } function doOneThing() { ...
1
vote
3answers
107 views

Split comma separated list ignoring commas within matching {}

I want to split a csv, but ignore any commas within matching curly brace groups, and loop through each of the list members. The code below works great but does not consider commas within curly brace ...
0
votes
0answers
17 views

ssh -f, running remote startkde, does not exit. Why?

I hope that someone already knows the answer to this, because I fear that trying to unravel the startkde shell script, and the subtleties of ssh -f is going to be ugly. I am opening a remote desktop ...
0
votes
1answer
35 views

Run a job inside a shell and check if it completed successfully or not? [closed]

I am trying to run a program inside a shell, whilst writing some information about the program into a file (pid & completed with error or not? if 0 completed successfully else, completed with ...
0
votes
1answer
32 views

Why can't my Unix terminal not find my matlab binaries and making Unix find them again?

This happens to be a new problem because I was able to run MATLAB on the shell until today. I didn't install or update it or anything of that sort, but now I am unable run matlab in the sell. It tells ...
1
vote
2answers
56 views

Crontab not running a shell script

Using account alex, I created: ~/pocketmine/pocketmine.sh When I manually run this using the same account, alex: cd pocketmine ./pocketmine.sh start It runs fine. I have added this to ...
4
votes
3answers
60 views

Force POSIX mode

Brace Expansion, eg {a,b,c} is not defined by POSIX. I would like to run my shell in POSIX mode. With Debian this is simple enough: $ bash -c 'echo {a,b,c}' a b c $ sh -c 'echo {a,b,c}' {a,b,c} ...
0
votes
3answers
75 views

How to group a bunch of rows based on information from the first row?

I have a data file looks like : 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 . . . 1 0 4 4 3 1 2 0 0 0 3 1 1 2 1 1 1 1 1 1 0 1 1 3 . . . 0 0 0 0 0 0 0 3 3 1 1 2 3 2 1 2 2 3 1 2 3 1 2 2 . . . ...
0
votes
2answers
73 views

Spaces in assignments in shell scripts

What is the difference between a. var=23 b. var =23 c. var= 23 d. var = 23 There is difference in space around the assignment operator. I am new to unix.
12
votes
3answers
264 views

Why is 'ls' suddenly surrounding items with spaces in single quotes?

I just noticed that on one of my machines (running Debian Sid) whenever I type ls any file name with spaces has single quotes surrounding it. I immediately checked my aliases, only to find them ...
11
votes
2answers
404 views

Why does `watch` make `ls /tmp` list contents of $HOME?

I'm trying to watch number of files in my /tmp/ directory. For this I thought this command would work: watch sh -c 'ls /tmp/|wc -l' But it appears to work as if ls had no arguments. Namely, I'm in ...
1
vote
0answers
25 views

Can I mask a program on the OS from the command line? [duplicate]

So, I wanted to know if it was possible to mask a running program (not visible from task manager) from the command line. Also, can I see all programs, hidden or otherwise from the command line?
0
votes
2answers
80 views

how to subtract first value from the last one within a column across a row in shell?

I have a data file looks like : 1 1 1 1 1 1 1 1 2 2 2 2 3 3 3 3 3 3 2 4 5 8 9 10 13 17 19 29 30 32 33 50 700 800 900 950 first I want to insert space among each 3 identical values keeping each ...