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)

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
15 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
22 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
2answers
28 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
91 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
34 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
26 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
48 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
25 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
53 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 ...
11
votes
4answers
269 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
315 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
45 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
0answers
46 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
40 views

generate file names in loop [on hold]

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 ...
0
votes
1answer
56 views

Is it possible to save data as per the incoming protocols in ascii?

I have connected my Raspberry PI 2 (Raspbian) to an automotive gateway via an Ethernet LAN. When I try tcpdump all packets are embedded together as per the Ethernet Frame protocol(From Ethernet ...
1
vote
2answers
48 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
20 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
24 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
34 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
30 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
99 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
16 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
33 views

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

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
31 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
1answer
40 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
59 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
72 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
72 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
224 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
393 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
70 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 ...
4
votes
1answer
342 views

How to trigger a 2nd command when a specific command is run in the shell?

I'll explain my question with example. I run $ python manage.py to perform some action. I want to run another command $ xyz , just when any user runs the previous command. Thus, from now on, ...
4
votes
1answer
56 views

How to remove a positional parameter from $@

Basically, I want to "pluck out" the first occurrence of -inf from the parameter list. (The remaining parameters will be passed along to a different command.) The script I have has the following ...
3
votes
1answer
67 views

performance regarding “find” arguments' orders

I'm curious whether there are some distinguishing performance differences with different filtering orders when using GNU find. For example, I hope to search all directories in current path whose ...
0
votes
2answers
43 views

Correct way to set PERMANENT environment variables from script

I want to do a very simple install process for my app framework. I've got everything working, but I want to set two environment variables. I want to update the PATH and also set a HOME variable. I ...
0
votes
0answers
10 views

Jinja to populate shell script

I have written a shell script that creates datadog dashboards (ref. datadog monitoring tool) for the a cluster. I want to call these scripts in salt-stack state and pillar files to make the whole ...
0
votes
2answers
40 views

Echo a string with a variable in it without expanding/evaluating it [closed]

I've searched everywhere. Tried echo and print. Tried single and double quotes. But I have parsed data and assigned it to a variable and would like to then evaluate it for if there is a variable ...
1
vote
2answers
30 views

Using getline with NR in awk

I have a bash script which calls a awk script to print each line from the file name_list.txt #!/bin/bash awk -f parse_list.awk name_list.txt In the awk script, I am using getline with NR to print ...
1
vote
2answers
35 views

Replace part of filename by directory name

I have folders named ACB* and in it among many other files, a couple of files called scanAC_* I want to delete the part called scanAC and replace it with the directory name it is in. For example, ...
0
votes
2answers
32 views

command not found error after giving permission to access file using chmod

I've been trying to run a script using chmod. Here's how I tried to execute the script: $ chmod u+x tester $ ./tester ./tester: Command not found. I always get the Command not found error and I'm ...
0
votes
1answer
16 views

Execute Terminal Command in Linux Kernel Hook

How do I execute the following command from a loadable Linux kernel hook: echo 5 > /sys/kernel/debug/ieee80211/phy0/ath9k/AggregationLimit
0
votes
1answer
17 views

get command line agrument by variable in shell script

I want to get the arg of a command from a var that has the index in it of the arg that I want. Something like this # command in terminal, `foo -r -f value_wanted` index="3" var=$"$index" echo $var ...
7
votes
2answers
700 views

What is the value of ${#1}?

Please explain the usage of ${#1} below: getlable () { if (( ${#1} == 0 )); then test="-"; else test="${1}"; fi; }
0
votes
0answers
30 views

Pg_dump does not work in Cron

I have the command below and run it succesfully: /usr/lib/postgresql/9.1/bin/pg_dump -U dspace --format=c --file=/dspacebkp/dspace_db_$(/bin/date +\%m\%d\%Y)_uncompressed dspace I can see my new ...
2
votes
2answers
49 views

How to append data to a variable using \n as separator?

The new line characters seem to be lost, even though they appear within quotes. foo= for i in 1 2 3; do foo="$foo$(printf '\n')$i" done echo "$foo" 123 Now in practice, I don't want to add a ...
0
votes
0answers
31 views

Git “unknown revision” error when within bash script

I'm writing a shell script that needs to perform certain operations based on the last commit's message of my local branches with a name starting with "task". Here's what my script looks like ...
5
votes
5answers
332 views

How to group lines in file by two?

I have a text file like this: a b c d e f g How can I group those lines to obtain an output like this: a-b b-c c-d d-e e-f f-g I have to do this in shell (sh, csh, bash). I have found this: ...
3
votes
2answers
62 views

What does “if echo $line | grep -F = &>/dev/null” do?

I'm not sure what the following line does in a bash script: if echo $line | grep -F = &>/dev/null then ... I know &>/dev/null is short for >/dev/null 2>&1, I'm not sure, ...