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

Handling NULL characters in shell

Is there a portable way of handling NULL characters in shell? A typical example would be splitting the output of find ... -print0 with shell (and shell only) either in a pipe or in a command ...
1
vote
3answers
41 views

Replacing a “time” column with corresponding values

I have a file in the following format: "2004-04-19 12:25:57" 44 44 "2004-04-19 13:39:32" 36 36 "2004-04-19 14:00:53" 34 34 I need 2 new files: a) A file which will replace "time" values of the ...
0
votes
1answer
13 views

Cannot disown mplayer?

mplayer -vo null -ao alsa test.mp3 & disown It returns sh: 1 : disown: not find Why it doesn't work?
0
votes
2answers
30 views

Copy files with different names from different directories

I am trying to copy multiple files with different names from different directories, to one same new directory. The names of the directories are the same as the beginning of each filename. For example ...
-5
votes
0answers
17 views

How can i write this script to fullfill my needs? [on hold]

In which I have a string ”mt school is over" If string is matches then i have to match binno-12245 If this matches then instno-4567 If this matches den i have to copy data from binno to next 11 line ...
1
vote
2answers
32 views

figure out ip addresses of all the machines remotely?

I have around 40 machines and I want to know what are their IP Address. One way is to login into those boxes and figure out their IP Address by using ifconfig command but is there any other simple way ...
16
votes
5answers
1k views

Why does [A-Z] match lowercase letters in bash?

In all shells I am aware of, rm [A-Z]* removes all files that start with an uppercase letter, but with bash this removes all files that start with a letter. As this problem exists on Linux and ...
0
votes
2answers
51 views

what if I need to put a “” inside a “” in bash shell? [on hold]

I have a shell script, in which there is a command: if [ -e "./${name}/\"$1\"_page.json" ]; I noticed that unlike many other languages, the \" doesn't work. What should I do?
1
vote
3answers
70 views

Is there a way to undo a terminal command?

I just copied a whole directory into another one using cp ~/local/* ./ and actually wanted to type cp ~/local/srl* ./ so I'm founding myself with a lot of unnecessary files. I can suppress them ...
-1
votes
1answer
14 views

save output into a file from sqlplus query in ksh script

The thing is that it overwrites in Result.txt and I only get the last query. How can I fix this? #!/bin/sh while read -r line do echo "'$line'" sqlplus -s whatever/whatever <<-EOF SPOOL ...
0
votes
1answer
88 views

What do these commands do?

I have been working at this company for around 8 years now and something that has always puzzled me is that we have a software supplier who often connects to our network to provide user support on ...
-1
votes
0answers
12 views

SFTP inside SFTP [duplicate]

I want to transfer files from serverB to ServerC while staying in serverA. Can we do sftp inside sftp in shell? If yes then how?
2
votes
2answers
117 views

What's the `name` argument to `sh` for/do?

Taken from FreeBSD's man page on sh (because its the most convenient online, target platform is Debian if it matters): SH(1) FreeBSD General Commands Manual SH(1) NAME sh -- ...
0
votes
1answer
21 views

Queue up multiple videos from Bash Script

-Skip to bold to skip the fluff - I'm new to ubuntu, so still learning the ropes of how bash scripting goes. I've got this code I've been working on, which works great. (side question - can I ...
1
vote
2answers
88 views

How to remove a file with two words separated by a space in the shell? [duplicate]

I made a text file called hello world in my home directory. Via the shell I am trying to remove it with the rm command. However, when I execute rm hello world the shell thinks that I am trying to ...
1
vote
1answer
32 views

Provide three argument to one option using getopts in bash

I am trying to process a command line using getopts in bash. I have to pass three arguments after -w option. For example, -w 1 do loop. It should print one line before and after each line from loop ...
0
votes
1answer
14 views

How to create a module on a CentOS cluster [on hold]

I would like to create a module on a CentOS 6 cluster (e.g. module load gcc-4.7.2). Basically, I have no clue how modules work. Are there any good tutorials illustrating this or could someone ...
0
votes
0answers
27 views

shell script in doing operation for 2 folder tree [duplicate]

I have a directory looks like: dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
1
vote
0answers
19 views

External monitor script has become unreliable

I have been using the following udev rule and bash script to automatically configure my external monitor for some time now, however recently the script has become unreliable, usually doing the ...
0
votes
1answer
21 views

How to spawn new processes for new instances of the same shell script?

I'm trying to lock a file using the command lock. It's syntax is ./lock </path/to/file/name> I need to lock a bunch of files in a given directory and in order to achieve this I'm using two ...
1
vote
1answer
32 views

Pass shell variables to SQL statement

I want to pass shell variables to sql statement. Both shell script and SQL statement are present in the same script file. I want the values of the variables retMonth, retLastDay and retPrvYear in the ...
14
votes
2answers
505 views

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

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
2answers
53 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, ...
-1
votes
0answers
14 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 ...
2
votes
1answer
28 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
64 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
46 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
45 views

How to pass arguments to a Java process from within a shell script [closed]

This may be a duplicate but the initial questions I have found the answer did not resolve the issue. Yet another re-write of the question. I have this Java application: public static void ...
-3
votes
1answer
44 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
33 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 ...
5
votes
4answers
348 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
28 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
31 views

Big XML - copy data from nth Occurrences to another file

<XML> <Employee> <firstname></firstname><lastname></lastname> </Employee> <Employee> ...
10
votes
2answers
462 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
3answers
91 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
19 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
49 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
37 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
67 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
29 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
14 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, ...
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
74 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 ...