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
1answer
20 views

compress all pdf files recursively

i want to compress all my pdf files in an given directory and its sub-directories using ghostscript. I´m stuck using the find command within loops by filename including spaces. Here some example ...
2
votes
2answers
184 views

Renaming using terminal and regexp to remove leading numbers from filenames

I want the following files to be renamed removing the sequence numbers. 01 X.mp3 to X.mp3 02 Add Me In.mp3 to Add Me In.mp3 I am trying with the below rename command. rename -v -n 's/^\d+\s*([a-z]+...
3
votes
2answers
47 views

Echo the list of process not running

I have developed a script, the script refers to a file to start the required processes on that server. The script times out after 180 secs. At the end of the script I would like to display the ...
0
votes
1answer
44 views

How to grep and treat meta character as normal character?

I am trying to recursively find some pattern which contains meta character. Pattern that I searching for is template <int N> I have tried : grep -F -lir "template <int N>" * # ...
3
votes
2answers
48 views

How can I stop vim from editing directories?

Sometimes I accidentally tell vim to edit a directory instead of a file in it vim directory-name # what I typed vim directory-name/blah.txt # what I meant to type Instead of immediately ...
5
votes
2answers
60 views

How to set an alias across all tty shells?

I set an alias in shell tt2 but it won't work in other tty shells, any idea how to make a system wide alias ?
2
votes
3answers
84 views

How complex can a program be written in pure bash? [on hold]

So after a very quick research, it seems bash/shell (whatever it is called) is a Turing-complete language : https://en.wikibooks.org/wiki/Bash_Shell_Scripting#What_is_Bash.3F I wonder, why is the ...
7
votes
2answers
368 views

Is there a way for shell script to know which program has executed it?

In *nix world, is there a way for shell script to have information about which program has executed it? Example: /path/to/script1 /path/to/script_xyz in this imaginary scenario, script_xyz would ...
2
votes
6answers
131 views

Renaming files from upper case to lower case

I need to elaborate a little bit more. These commands are actually for a BBS FTN tosser. The configuration file for which these commands reside in, only allow specific declarations. Here are a few ...
6
votes
2answers
376 views

Why does changing $PATH affect child shells, but changing $foo not?

$ unset foo $ unset bar $ echo $foo $ echo $bar $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games $ foo=a $ bar=b $ export bar $ echo $foo a $ ...
2
votes
1answer
57 views

Why do my single quotes vanish on substitution with sed

What is the right command for: sudo sed -i '/, false);/adefine( 'WP_MEMORY_LIMIT', '64M' );' /var/www/html/wp-config.php The result is: define( WP_MEMORY_LIMIT, 64M ); instead of the desired: ...
1
vote
1answer
32 views

cat into stdin then pipe into program keeps forked shell open, why?

I'm not sure what's going on but I've been trying to understand what is happening with the input and output. So here is my program. #include <stdio.h> #include <stdlib.h> int main(){ ...
0
votes
1answer
13 views

How to list SVN repository name with latest revision number

I want to get for each of my SVN repository its latest revision number. My command looks like currently like this: ls | xargs -n 1 svnlook youngest This prints a list of revision numbers. But I'd ...
0
votes
0answers
18 views

Input Return Key In A Sql script

I have a sql script which when run prompts me to input a value, if i don't input any value and press the enter/return key it will select the default value and will pull all the records. I am trying to ...
5
votes
2answers
385 views

Shell script: if multiple conditions

I want to create a shell script that echos something if 3 directories don't exist. Here is the code I wrote: test.sh: if [ ! -d "/home/unix/POSTagger2" ] || [! -d "/home/unix/POSTagger2/stanford-...
1
vote
1answer
34 views

How to set a path variable without root acess? [duplicate]

My college currently uses a very old (like 3 years old) openJDK 1.7 distribution. And being a student, obviously I don't have root privileges. I wanted to use a much later version downloaded a much ...
2
votes
2answers
35 views

how to check variable existence and compare with the string in busybox?

I want to use something like that if [[ ! -z "$ENV" && $ENV == 'production' ]]; then echo "production"; else echo "dev"; fi but in BusyBox it does not work :( sh: 1: [[: not found It ...
-3
votes
0answers
32 views

sed replace string in file with shell

Line in the file : def customerName = "TEST" Want to replace the TEST by the script argument input($1). Shell Script: The command which is giving TEST as output is : strReplace=`cat $filePath | ...
0
votes
1answer
58 views

Read Input From Command Line

Trying to use the "read command" to accept user input from the command prompt itself but my script doesnt seem to be moving forward echo "Do you want to continue?(yes/no)" read -p $1 if [ "$1" == "...
2
votes
1answer
39 views

Is aliasing over a coreutil command a bad idea? [closed]

I frequently find myself copying large directories and then thinking "darn, I should've used rsync instead of cp for this because I can get progress updates". I'm considering adding this to my ....
1
vote
1answer
32 views

store file with invalid characters

Some files we get from a customer could not be processed properly because they were declared as US-ASCII but contained invalid characters. In order to validate a software fix, I am trying to copy ...
18
votes
4answers
2k views

What's the difference between eval and exec?

eval and exec are both builtin commands of Bash (1) that execute commands. I also see exec has a few options, but that is the only difference?
0
votes
1answer
43 views

Undo last command possible? [duplicate]

In windows you can undo an operation if you press CTRL+Z. E.g. you delete a file in the gui then press CTRL+Z and the file will be restored and appears in the folder again. Is there something similar ...
0
votes
0answers
16 views

print out anything in between “function $argument” to “}”, where $argument is the function name, of a given file [duplicate]

Let's say, i have some functions defined inside my ~/.zshrc function foo() { # do some stuff } function bar() { # do # lots # of # stuff } I search basically for a way to ...
1
vote
2answers
42 views

How to run a bash script from a sh(dash) script?

I have a sh (shebang #!/bin/sh) script (sh.sh) which invokes a bash (shebang #!/bin/bash) sub-script: . "some-path/bash.sh" In the bash script I have a declaration of an associative array: declare -...
1
vote
1answer
37 views

Segmentation fault when calling a recursive bash function

I have hundreds of multiple folders which contains thousands of zip files which contain nested within the zip files like show on three below start tree structure 012016/ ├── 2016-01 │   └── 2016-01 │ ...
3
votes
2answers
46 views

Problem with spaces when used in find command

I'm trying to place a zip file with the content of the directory in each directory that doesn't contain any subdirectory. The following command works if there's no space in dirnames and/or filenames ...
-1
votes
1answer
36 views

How to change the directories when the program run in pipeline [closed]

I am running a block of commands in a shell script. When I tried the cd command with its directory path at the middle of the code, the program didn't compile at all. For example: mkdir kmer_21,...
0
votes
0answers
13 views

My tcsh say “Unmatched” or “No directory or file found”

I have .csh script. When I want to execute it with source 8.csh Some times it says, no directory or file found some times it says unmatched. I realized another problem too. I can see 8.csh in ...
3
votes
1answer
45 views

set -e in a subshell

I thought set -e had the same effect on subshells as on top-level shell. Apparently, it does not. This: ( set -e false true ) || echo false1 bash -ec ' set -e false true ' || echo ...
0
votes
1answer
16 views

Yakuake is not restoring my appearance settings

Yakuake is not restoring my appearance settings on startup. The settings are saved to disk, as far as I can tell with strace, is being read by Yakuake. However, Yakuake uses default settings ...
-4
votes
0answers
24 views

How to determine current users who are logged in using a specific domain? [duplicate]

I want to know How to determine current users who are logged in using a specific domain? For example, here is the question. Please tell according to it using the grep command and use of wc. ...
-6
votes
1answer
49 views

How to determine current users who are logged in using a specific domain? | UNIX [closed]

I want to know How to determine current users who are logged in using a specific domain? For example, here is the question. Please tell according to it using the grep command and use of wc. ...
-3
votes
0answers
35 views

Outer loop stops without reading all lines of files when inside loop finishes in a nested while loop [closed]

I'm trying to use the below script to repeat actions to each line of the FILE. Inside the read while loop, I use another while loop to control the SYSTEM_COUNTER not to exceed MAX so that the system ...
1
vote
1answer
36 views

xterm not loading xresources properly

There are similar questions out there, however, I was not able to figure out the flaws in my .xinitrc file which causes .Xresources not to load. The respective .xinitrc #!/bin/sh [[ -f ~/.Xresources ...
1
vote
2answers
41 views

Syntax Error near Unexpected Token in a bash function definition [closed]

Forgive me; I'm pretty new to bash files and the like. Here is a copy of my .bashrc: alias k='kate 2>/dev/null 1>&2 & disown' function kk {kate 2>/dev/null 1>&2 & disown}...
1
vote
1answer
38 views

create listening port on IPV6 WITHOUT netcat

I wish to be able to listen to a port (eventually creating a bind shell) on an IPV6 address. I have tried using the netcat installed on the linux (debian) machine I am trying to bind. sadly it seems ...
0
votes
1answer
24 views

Copy folders has specific part of name and it is content

I have a long list of folder as follow: 001_bat_3513 002_mon_3213 003_bat_3515 004_btt_3540 005_bat_4513 055_bpt_8523 056_bot_3513 058_bat_1513 . . From this list: How can I copy the folders ( and ...
3
votes
5answers
342 views

When I redirect the output of ls to a file, the filename is included in that file. How can I avoid this?

Observe: $ ls $ ls > list $ cat list list This appears to indicate that when ls is executed that the redirection into file list has already begun and the list file is already created. A fine ...
0
votes
0answers
30 views

How To Create Soft Links To An Entire Directory Structure Which Has Sub-Directories, Files Etc! [duplicate]

I'd like to: Create a soft link for a directory or file. But have a scenario where I need to create soft links, to a directory which has multiple sub-directories, files etc. I wanted to loop across ...
1
vote
0answers
29 views

Save return value from a function in one of its own parameters

Function: Func1() { str1=$2 $1=$str1 } Call function: local var1 Func1 var1 "Helle World" echo $var1 I know this will work but I guess it's not very "pretty": Func1() { str1=$2 eval ...
4
votes
2answers
77 views

How to use a special character as a normal one?

Many questions like 'How to type the double-quote char (")?' are being asked, and we don't want to clutter our community with the same answer (Type it as \" if not enclosed in 's, " if enclosed in 's.)...
0
votes
2answers
31 views

How to delete files in directory

I have to delete one particular file in each directory. Can you help me with any shell script to do? Example: MKRUW, DKRUW, TKRUW In each of these directories I need to enter MKRUW/default/file and ...
3
votes
1answer
230 views

How to count occurances of phrase in grep, ignoring case?

I need to search for a name nicolas bomber with grep. Name can also be NiCoLaS BomBer. I need to run a .sh file which display the number of occurrences of that name. The command I made is this one: ...
1
vote
1answer
25 views

How to set which shell does Midnight Commander use?

As far as I know, Midnight Commander should be able to run different shells within it (the line second to the bottom). My question is, where/how can I configure which shell does mc use? Thanks!
2
votes
3answers
108 views

Writing an unlimited number of defined values into a file [closed]

I can use /dev/zero or /dev/urandom to write values into a file. Is there also a way to write an unlimited amount (just restricted by a command line switch maybe) of defined numbers (e.g. 1, 2, etc.) ...
0
votes
1answer
43 views

Script for automatic gateway switching

I have two network connections. If one goes down other should come up automatically how i can do it with a shell script in Ubuntu 12.04
0
votes
1answer
25 views

What is Alternative of initlog (present in RHEL5) but deprecated in RHEL6?

I am using initlog tool in a cron file to write the output of ntpq -p command in syslog.. But initlog command has been deprecated in RHEL6. Now, I want know the alternative of initlog command in ...
0
votes
0answers
20 views

Set variables into script before or after SCP [duplicate]

I have two scripts out and disk_check.sh. The main script is the out which exports multiple variables but I need two variables set in disk_check.sh which are: VOL and VM_VOLUME. So my out script ...
2
votes
2answers
234 views

Dropping a process into the background

If I have started a process, and it spends more time than I anticipated, and I regret not having said rm foo & rather than rm foo, can I do something to drop it into the background?