The tag has no usage guidance.

learn more… | top users | synonyms

4
votes
4answers
2k views

/bin/sh source from stdin (from other program) not file

Kind of a tricky one to name this... Basically I have a program which when run prints on STDOUT a set of shell variables: $ ./settings SETTING_ONE="this is setting one" SETTING_TWO="This is the ...
0
votes
1answer
32 views

How to run script menu after new terminal window exits

I have a script that asks the user for input for options. When selecting the option I have it so it runs a new terminal and executes another script for the specified option. I still want the menu ...
0
votes
2answers
33 views

Whitespace treatment in OS X vs Linux in Bash

I am trying to run a very simple script on a few different platforms: #!/bin/bash STRING="this is a test" echo $STRING , and I cannot tell why on Mavericks and Yosemite I get the output: ...
0
votes
1answer
92 views

Linux sh script throws “#!/bin/sh: not found”

i have a script #!/bin/sh # Automatically remove a torrent and delete its data after a specified period of # time (in seconds). TARGET=/var/www/transmission/completed USER=name PASS=pass ...
0
votes
1answer
48 views

Double exit in gzexe

I have seen in gzexe (source) they use the following pattern used in a lot of places all over the file: (exit $res); exit $res What purpose does the exit inside the sub-shell? Doesn't seem to do ...
0
votes
1answer
135 views

Can't install android studio on linux mint 17.2

I have downloaded android studio for linux , after unzipping the zip file I went to specif location which is android-studion/bin and open terminal there then i run ./studio.sh command , when I run ...
0
votes
1answer
38 views

Why does sh not find files in my path that do exist?

When I type this in sh it outputs : $ $PATH sh: 12: /bin:/usr/bin: not found But, I do have a /usr/bin folder, and it's fuuuuull of stuff. Same thing with zsh: ▶ $PATH zsh: no such file or ...
0
votes
1answer
2k views

Running sh.exe in windows cmd.exe: command not found

For some reason I need to run a (hopefully simple) sh file under Windows and be able to do so from another application. I can do that using cygwin, but for various reasons I need this operation to be ...
6
votes
4answers
12k views

How do I change my default shell to bash if I don't have access to chsh nor /etc/passwd?

I'm working on a university remote Linux account, and the default shell is sadly csh without tab completion. How can I change my account's default shell to bash? chsh is not available.
7
votes
8answers
726 views

Remove linux file named with set of shell responsive characters

I've created a file named \;:$"\' to test a software of mine. I ended up with an error, because I cannot delete the file property. I'm trying to find a precise character combination to remove it via ...
0
votes
1answer
20 views

How can I append text in the middle of a pipeline?

With cat its possible to append a file to the data passing through a pipeline: foo | cat - somefile.txt | bar Is there a command that lets me append text without using an intermediate file? foo | ...
2
votes
4answers
4k views

Change the sudo su shell

Whenever I run sudo su from my normal zsh (which uses the oh-my-zsh framework), I'm forced to use the old Bourne shell (sh) by default (obviously; this is standard behaviour on most *nix-like ...
0
votes
2answers
91 views

sh -c in background

Original version: How to run sudo sh -c "command" in back ground In a terminal sudo sh -c "command" & starts in background but as soon as I press enter, the process exits [test@localhost ...
1
vote
2answers
109 views

Is there a way to have sh/bash/zsh “case” use a variable for a test value?

I'd like to have something like the following: #!/bin/sh # ... other stuff ... # some relatively static possibilities (srsp): srsp='this|or|that|the|other' # more other stuff case $something in ...
0
votes
1answer
110 views

How do I save a string of numbers from an ongoing command to a list in a shell script?

I am trying to make a shell script for recording macros via recording the individual keycodes of each button press. The command for it looks like this: xev | grep -A2 --line-buffered '^Key*' | sed ...
0
votes
1answer
57 views

How to extract a substring and add it to original string with sed?

I am trying to write an sh script witch receives a string as input, extracts a particular substring and adds it after an specified expression to the input string. I tried a lot with sed -i'N ... but ...
20
votes
3answers
44k views

Which command in the Linux/UNIX sh shell returns my current directory?

Using the sh shell (not bash), which command in Linux/UNIX prints out my current directory? $ *showmewhereiam* /sys/kernel/debug $
3
votes
1answer
78 views

How do I prepend a string to program output without waiting for the whole line?

I have a script that runs a command on a remote server using SSH. I want to prepend the string Remote: to every line of the output, but I don't want each line to be delayed until the whole line is ...
0
votes
0answers
21 views

Configure a default shell script environment

Is there any way to change the default environment when running sh -c <command>? It appears that .cshrc is not called when running command with a -c flag.
0
votes
0answers
39 views

costumising sh behavior using prerunning script (like rc file)

my university has a linux server which we (students) can connect to and run staff. the default shell for this server is configured to be 'sh' (chsh command says "user does not exist in /etc/passwd" ...
0
votes
3answers
5k views

Make .sh file executable

I have a .sh file which is not becoming an executable. I tried doing it in the properties but as soon I ticked the checkbox, the tick vanished in a second. I then tried sudo chmod +x filename.sh ...
0
votes
1answer
23 views

cd to newest directory

Not strictly bash, but rather Bourne shell if possible. How can I programmatically cd to the newest directory? I want to install the latest package of whatever software, which is located in the newest ...
-2
votes
1answer
59 views

Bash executing command

Can anyone please give me the list generated by this : -{ for i in {1..100}; do lynx -dump -nonumbers -listonly [http]://www.dailymotion.com/user/MTDCafe/$i ...
0
votes
1answer
135 views

Bash scripts executed together don't kill background processes

I have a number of shell scripts that work very similarly to this question. Each script fires up a few background tasks, remembers their PIDs with $!, does some testing, and then kills the background ...
1
vote
1answer
28 views

Evaluating false in bash with multiple commands without a subshell

Bash evaluates the logical operators such that && always takes precedence. So for example: false || echo 1 && echo 2 1 2 and true || echo 1 && echo 2 2 Ok. So lets say I ...
12
votes
3answers
57k views

How to display current path in command prompt in linux's sh (not bash)?

I would like to display current path in sh prompt (not bash shell), which currently just shows "#", I tried with introducing this env PS1="$(whoami)@$(hostname):$(pwd)" and set ...
1
vote
3answers
59 views

Most efficient log “echo date”?

My coworkers write scripts with lines like this: echo "nightly $MACHINE restart begins at" `date` Which outputs something like this: nightly whitestar restart begins at Mon Oct 13 22:05:01 EDT ...
1
vote
1answer
352 views

Is there a way to “source” a sh script from the fish shell?

I like to put many of my environment variable definitions in the .profile script. If I am using a POSIX-compatible interactive shell like bash, I can use the source command to re-export the ...
2
votes
1answer
61 views

Pipe standard error to file and keep it on standard error?

I have a script (fragment) for which I'm logging output and standard error: #!/bin/sh #... { date "+%Y-%m-%d %T" cd $workdir ls -ltr validfile badfile #example command that provides stdout, ...
1
vote
1answer
714 views

Background Jobs from cron

I am running a cron on every two minutes. From the cron I am running other shell scripts in background with "&". After cron exits spawned shell script process still runs, this is desired behavior. ...
1
vote
1answer
105 views

Bash - list files within date range

So far I've been basing my efforts around this blog and have come up with: startdate=”201407010000? enddate=”201408010000? touch -t $startdate ./startdatefiles touch -t $enddate ./enddatefiles find ...
0
votes
1answer
1k views

unable to execute: Too many levels of symbolic links

By mistake, I executed these commands : sudo ln -sf bash /bin/sh sudo ln -sf bash /bin/bash When I rebooted the Linux server in recovery mode I got this message: init : Failed to spawn ...
0
votes
1answer
25 views

why following script is failing?

#!/bin/sh declare -a LIST= ('a' 'b' 'c' ) is failing on Ubuntu on which /bin/sh is softlink to /bin/dash How can I declare list which will be supportable on all kind of shell ?
0
votes
1answer
22 views

Autostarting a script at boot doesn't recognize the function “function”

I'm trying to get a script containing a function to run just after root autologin on TinyCore 5.3. The script works fine if I launch it from the prompt after login like this ./script.sh But when I add ...
0
votes
3answers
203 views

How to find length of string in shell

i need to calculate it using pure sh shell only. What happening is /bin/sh is actually a soft link to bash or other shell.Hence ${#STRING} gives length of string as it is advance bash feature. Can ...
1
vote
2answers
33 views

two processes are listed for one shellscript?

I have a shell script which does somewhat simple. #!/bin/sh do something boring... When I execute the shell script like this, $ nohup sh mysh.sh > /null/dev/ 2>&1 & I see there are ...
0
votes
1answer
89 views

Memory usage of a process in a shell script

I want to find out the memory usage of a process in a shell script.I tried to use this piece of code : while[process] do if [ -e /proc/$pidno/statm ]; then m=`awk '{OFS="\t";print ...
0
votes
1answer
71 views

sh + how to run command and set it into parameter ( VAL )

please take look on the following commands down, ( the shell is sh ) something not clearly for me when I run - eval echo \$arr$n , I get the value a as expected so why: VAL=eval echo \$arr$n , ...
0
votes
2answers
441 views

Getting errors trying to run shell script (Linux)

I'm trying to run the following script. I have run it before without issue, but now I encounter an error. #!/bin/bash # init function pause(){ read -p "$*" } echo & echo "(Website):" ...
1
vote
1answer
1k views

Bash error while running script

I have a CentOS 6.5 64-bit dedicated server. The only thing I done on it is yum install java7, so I have not installed any other stuff. So in the directory /root I made this file (test.sh) ...
4
votes
2answers
1k views

shell script to replace a keyword in a file with the contents of another file

I'm to create a .sh to replace a specific keyword in a file using the contents of an other file. template.html contains a unique string "PLACEHOLDER" it must be replaced with the contents of file ...
5
votes
3answers
147 views

CD into directory with “-” in the beginning

I have a problem with cd-ing into folder named "--Recovery Files" and can't remember how to escape dashes in the filename. Any ideas?
0
votes
2answers
72 views

What is the risk when editing crontab file without the “crontab -e” command?

I developed a script in which I add lines to the crontab file with echo command and I remove lines with sed command. I do not know the risk of that especially that I find in some web site that we ...
2
votes
2answers
304 views

Record bash_history to private database for all users?

I want to be able to setup a MySQL database and record all commands issued on my server by username and command. Is this possible, and if so, how would I set it up?
0
votes
2answers
103 views

Copy shell configuration from one machine to another?

I've got login to another server where shell configurations are not like I would want. For example I don't see my username and CWD on prompt, and when I press arrow key, instead of giving last entered ...
1
vote
1answer
349 views

what cygwin packages do I need to install to be able to run commands from cmd.exe on windows?

I am trying to install JSCover, I snooped around and figured that to run .sh files on windows, the easiest option is to install cygwin. Which cygwin packages do I need to install to be able to run ...
133
votes
4answers
138k views

How can I resume a stopped job in Linux?

How can I resume a stopped job in Linux? I was using emacs and accidentally hit ctrl-z which blasted me back to the console. I can see it when I type 'jobs' [*****]$ jobs [1]+ Stopped ...
0
votes
1answer
315 views

Loop until user presses 'C' in sh file

What I want is as follows: At first when user runs .sh file it displays following: Review id: You id is:XXX000YYY Do you want to change it?[Press Y to change, C to continue]: Now If user presses Y ...
3
votes
1answer
1k views

Redirect stdout/stderr of a background job from console to a log file?

I just run a job (assume foo.sh). ./foo.sh [Press Ctrl-Z to stop] bg # enter background And it generate output to stdout and stderr. Is there any method to redirect to stdout and stderr to other ...
1
vote
0answers
527 views

execl: couldn't exec `/bin/sh'

I accidentally moved the whole bin, boot, dev and etc directory. After moving everything back I get the following error email from various cron jobs: execl: couldn't exec `/bin/sh' execl: No such ...