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)

6
votes
2answers
98 views

What does CTRL+4 (and CTRL+\) do in bash or readline?

I just found out by accident that CTRL + 4 closes programs reading stdin input from the command-line. This is how it looks when I type CTRL + 4 or CTRL + / into programs reading stdin ryvnf:~$ ...
1
vote
1answer
27 views

How to use ln -s to create a command line shortcut?

I have an sh file that I would like to be able to open from the terminal at any time. I would like to type "studio" into the terminal, and have android studio open I recall using ln -s to do this, ...
0
votes
0answers
12 views

Debian Linux Shell has no colors and desktop files/folders gone GNOME

Hello I have installed some packages to fix sound mute, but instead, after restart I saw no icons on desktop except 'Computer'. I have opened shell and wanted to do apt-get update but saw that the ...
1
vote
1answer
17 views

What files were sourced, zsh

I use oh-my-zsh with zpretzo, and I keep forgetting the zsh files it sources that I want to edit. How can I ask the shell what source files it sourced?
1
vote
2answers
60 views

Need output in a good format using shell script

I have a file, PoolReport.txt. Here is some sample data: Thu, Aug 27, 2015 7:56:29 AM PoolName,Total GB,Used GB ,Available GB ,Percent Full Oracle-RAID10,6432.539,6179.295,253.244,96.063 ...
0
votes
3answers
42 views

Rename files in directory according to name of directory

I am trying to rename a bunch of files according to the names of their directory in Linux, SSH. I have a directory called XYZ01smith. In it are four files called smith_5*.I need to add prefix XYZ01 ...
0
votes
1answer
28 views

How to pass an argument to a java process from within a shell script [on hold]

This may be a duplicate but the initial questions I have found did not resolve the issue. We have a script which calls a java process with arguments, one of the arguments has spaces in it. When ...
-3
votes
1answer
40 views

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
2
votes
3answers
31 views

echo and command substitution

I wrote a very basic script of command substitution which is below: #!/bin/bash files=$(ls *.fastq); echo $files The directory contains bunch of .fastq file and I just want to use echo command to ...
4
votes
4answers
333 views

$@ except the 1st argument

I need to write a shell script that runs in this way: ./myscript arg1 arg2_1 arg2_2 arg2_3 ....... arg2_# there is a for loop inside script for i in $@ However, as I know, $@ includes $1 up to ...
1
vote
1answer
25 views

Check if multiple files exist in directory

How to find multiple files present in a directory in ksh (on AIX) I am trying below one: if [ $# -lt 1 ];then echo "Please enter the path" exit fi path=$1 if [ [ ! f $path/cc*.csv ] ...
0
votes
1answer
29 views

Big XML - copy data from nth Occurrences to another file

<XML> <Employee> <firstname></firstname><lastname></lastname> </Employee> <Employee> ...
9
votes
2answers
382 views

How does a shell execute a program?

If I compile a program using gcc, and try to execute it from the bash shell, what is the exact sequence of steps followed by bash to execute it ? I know fork(), execve(), loader, dynamic linker (and ...
2
votes
2answers
42 views

List transient files by numerical value having number greater than a given constantly varying filename

I've a directory having constantly changing filenames (by numerical value) listed as: -rw-rw----. 1 root root 10493952 May 7 10:39 A0000000.LOG -rw-rw----. 1 root root 10493952 May 7 08:38 ...
0
votes
0answers
27 views

How do I send a variable through SSH so it can be used across servers? C Shell

EDIT: Would this be possible in bash? Note: I have to use C shell. (.csh) I have something very similar to the following code: set var = "string" ssh -X server "$var" << END * I ...
1
vote
0answers
7 views

Global [multiple sessions] directory stack

For the current zsh session I use dirs -v command to print the directory stack. I'd like to have an analogous tool that shows me the directory stack of all sessions, also the closed ones. Or if not a ...
1
vote
1answer
18 views

adb pull not accepting a variable as source, gives *' does not exist..* error

I'm trying to use $EXTERNAL_STORAGE in the adb pull command. I noticed that the variable has its scope defined in Android only and so it would not work successfully in adb pull ...
1
vote
1answer
42 views

How to print the line numbers with corresponding line that matches a pattern using shell command? [duplicate]

File, .false alarm is bla no. 11 .no alarm generated is bla .application will be killed is bla wall command .doc file is document file with .doc extension .no authority for this selection bla Now ...
0
votes
1answer
41 views

Silently timeout command in zsh

This is an oft-asked question: Superuser/loop-start-program-and-kill-after-time-out SO/bash-script-that-kills-a-child-process-after-a-given-timeout SO/bash-run-a-process-for-limited-time-period ...
0
votes
2answers
37 views

How to store whole a paragraph as one element of array in bash script

I am using the following code to read data from a file abcd.txt and try to store in an array parameters, I am able to store 619617 in parameter[0] and update in parameters[1] but in parameters[2] I am ...
0
votes
1answer
36 views

Scripts in rc.local (start at boot), doesnot start

In my Debian /etc/rc.local, I've put 2 scripts (one for Wifi AP, the other for VPN client-connection): sh /bootscripts/vpn.sh & sh /bootscripts/wifiap.sh & #test: date >> ...
0
votes
1answer
22 views

sed command to delete variable number of lines

To delete the first 10 lines from a text file, the following command is used: sed -i -e "1,10d" filename what if I want to delete n number of lines, where n is a variable. i.e. I am using ...
1
vote
2answers
61 views

Cron only occasionally sends e-mail on output and errors

On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable: (echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable" This is ...
0
votes
1answer
26 views

DNS Query Script

I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and ...
0
votes
0answers
11 views

Zenity. How to run as an application?

I built a script (bash), then I overlaid it with Zenity (to have a progressbar in a GUI for non linuxian users). How can I deliver it as an app, not a .sh ? And never show a square of terminal ?
0
votes
1answer
16 views

Is there a GUI debugger for csh script?

I have read another question in UNIX & LINUX stack exchange. The GUI provided in that question can be used to bebug *.sh file. How about to debug *.csh file? What other plugins for eclipse can I ...
0
votes
1answer
20 views

Running repetitive task through Bash script

I'm running a few repetitive tasks and I think will be good to create a small bash script to perform all them in just one command: run the bash script. This are the tasks I need to run: # stop HTTPD, ...
-1
votes
0answers
25 views

Shell Script Flashing [closed]

I created my first shell script. It's an audio logger that runs on the hour for an hour and restarts. Although if it is started within the hour it will only run until the end of the hour. I've added ...
0
votes
2answers
30 views

Breaking up a file into two parts based on a particular line [duplicate]

I need to breakup a file into two separate files based on a particular line for example: . . sc_outfifo 0.000E+00 0.000E+00 0.000E+00 0.000E+00 1.586E-02 1.586E-02 1.586E-02 Fub_Level_DACGE(%) ...
0
votes
4answers
72 views

How can I test for the .RAW file extension?

I'm trying to set up an sh script that will run every 30 minutes. During each run, I want to check a directory for the presence of at least one .RAW file. Upon finding that file extension, I will have ...
0
votes
1answer
15 views

not getting variable's values inside the isql command

Below I am trying to automate the Sybase reporting job but unable to get the variable value as sp_helpdb proc's parameter. Kindly assist me to get out of this. #!/bin/sh . ./SYBASE.sh dblist=`isql ...
2
votes
0answers
21 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
2
votes
2answers
34 views

automating CentOS 7 configuration using shell scripts

I notice I spend a lot of time using tutorials to manually configure a CentOS 7 server. How can I convert the manual steps from a tutorial into an automated shell script that can be used to configure ...
2
votes
1answer
23 views

Can a process bring itself back to the foreground on completion? (AIX/ksh)

I have a while loop to count to 5 and echo "Done" when finished. I want to be able to execute the script in the background with "&" and continuing issuing commands while it runs. But when it's ...
5
votes
1answer
273 views

How to create files named 'a to z' - any trick? [duplicate]

I need to create 26 files named a to z in single command. I thought touch command would be sufficient with the regex, but it doesn't expand [a-z] instead it creates a single file with name "[a-z]". $ ...
2
votes
1answer
87 views

Why root bash output is colored but `sudo ls` output is not?

In bash (Ubuntu) I get colored outputs either as root (after sudo su) or as a normal user. I checked (after reading this post) the files .bashrc for normal user and superuser and the options related ...
1
vote
2answers
28 views

List all directories whose contents (files) have not been updated or accessed before a certain date?

Would like to easily located folders to archive/trash and an easy way to automate this would be to choose folders I haven't made any use of for years. Since folders themselves can have different ...
2
votes
2answers
51 views

Alias doesn't seem to read from STDIN

I'm looking for an alias to convert hex from hexdump output into "Python's" hex notation: $ echo "5f 74 34 0c c9 7b 9f f8 7a 7c 46 ff ff 5c 31 26" | sed 's/ */\\x/g' | awk '{print "\\x"$0}' ...
0
votes
1answer
41 views

Shell script for logrotating

I want to create a shell script for logrotating. following are my requirement. want to archive the log files to a particular directory lets(/usr/local/jboss-5.10..GA/server/archive/log) older than ...
0
votes
0answers
50 views

Script won't run in cron but runs fine in root shell

My Problem: I have a python script that runs fine when run manually but does not complete when run using cron. My script fails in cron because it contains pexpect commands that require an interactive ...
0
votes
0answers
35 views

Subtract a Number from variable which contains a sentence

This is extended question from http://stackoverflow.com/questions/32081168/reading-a-log-file-with-different-sequences-using-shell-script I'm new to shell. I've written a shell script a code with ...
1
vote
2answers
28 views

Automatic Background Processes

I'm running my Raspberry Pi off an SSH server, and want to be able to access it out of home. Sure, all I need is an IP. But with my terrible internet, it's constantly dropping out. My IP is constantly ...
-2
votes
0answers
32 views

df and du differences too large [duplicate]

-bash-3.2$ df -h | grep /mnt/opt /mnt/opt 197G **163G** 32G 84% /mnt/opt -bash-3.2$ du -sh /mnt/opt **74G** /mnt/opt More then 1/2 the differences between df and du. ...
0
votes
2answers
29 views

How to pass an environment variable when change rooting?

I don't seem to be able to pass an environment variable to a chroot: $ sudo apt-get install debootstrap dchroot $ sudo debootstrap trusty mychroot $ sudo chroot mychroot /bin/bash -c "MY_VAR=5; echo ...
2
votes
1answer
60 views

n-factor SSH authentication for CentOS 7

How can I enable (and require) n-factor authentication for all SSH connections to a CentOS 7 server? I have read about Google Authenticator, which provides two factor authentication. But that is ...
1
vote
2answers
47 views

How to subtract lines, in reverse, only if greater than previous line

I am working on a shell script that will read the lines of a file, in reverse. I need it to subtract the previous line from the latter, but only if the latter is larger. If it's smaller, then I just ...
0
votes
3answers
52 views

regex in `/bin/sh` shell

I would like to remove all files ending with a given set of extensions in a particular directory in a /bin/sh shell. With a /bin/bash I can do it with regex like this : rm path/(*.pdf|*.png) but ...
5
votes
2answers
43 views

posix placement of stdin redirection (<in cmd vs cmd <in)

I always write stdin redirection after the command, because for me it's more natural to have first the command and then the redirections (if any): some-command < input-file > output-file For ...
2
votes
0answers
14 views

restrict private apt repository with rssh - why does apt-get try /bin/sh?

I am trying to set up a private repository via ssh. My sources.list.d/ contains the entry deb ssh://user@host:/repo ./ user is a certificate only account on host. apt-get update works fine. ...
0
votes
4answers
38 views

Clearing the content of files by size

Considering if I list files in a directory: drwx--x--x 43 root wheel 4.0K Aug 18 12:52 .. -rw------- 1 root root 268K Aug 18 04:31 build_locale_databases_log -rw------- 1 root root 5.2M Aug 18 ...