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
2answers
22 views

what if I need to put a “” inside a “” in bash shell?

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
votes
1answer
10 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
76 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
107 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
20 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
85 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
29 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
18 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
20 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
29 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
474 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
50 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
45 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
40 views

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

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
42 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
32 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
347 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
27 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
30 views

Big XML - copy data from nth Occurrences to another file

<XML> <Employee> <firstname></firstname><lastname></lastname> </Employee> <Employee> ...
10
votes
2answers
444 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
75 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
45 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
65 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
13 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
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 ...
0
votes
1answer
18 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
39 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
276 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
90 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
30 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 ...