The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
16 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
35 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
65 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
23 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 ...
0
votes
1answer
55 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 ...
1
vote
3answers
44 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 ...
0
votes
1answer
335 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 ...
2
votes
1answer
26 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
51 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
378 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
23 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
14 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
48 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 ...
0
votes
0answers
13 views

How to write `dmenu` wrapper script?

I could not find how to set global default options for dmenu(actually dmenu2). So I tried to write wrapper script. #!/bin/sh dmenu -l 10 -fn "Noto Sans-20:bold" -y 200 -i "$@" < /dev/stdin But ...
1
vote
2answers
28 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
66 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
41 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
284 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
489 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
492 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 ...
0
votes
0answers
12 views

Trying to find dbus session, doesent work

Trying to use notify-send with cron, it needs dbus, what im i doing wrong? var= $(set | grep '^DBUS_SESSION_BUS_ADDRESS=') export DBUS_SESSION_BUS_ADDRESS=$var #!/bin/sh { ...
0
votes
0answers
57 views

Make a script identify DBUS session address and use it

I'm using cron with notify-send to display some notifications, but it requires DBUS session to run Here is the script: export DBUS_SESSION_BUS_ADDRESS=[session] #!/bin/sh { DISPLAY=:0 ...
-1
votes
2answers
40 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 ...
0
votes
0answers
57 views

Idle timeout Bourne-style shell

Is there any way to timeout idle users in Bourne-style shell (/bin/sh). man sh does not talk about it. http://www.freebsd.org/cgi/man.cgi?sh TIMEOUT or TMOUT shell env variables in /etc/profile ...
0
votes
2answers
46 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
149 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 ...
3
votes
1answer
779 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
350 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 ...
0
votes
1answer
511 views

How can I encode an url for wget?

I am looking for a way to convert a string to a clean url. For example : wget http://myurl.com/toto/foo bar.jpg This is going to download http://myurl.com/toto/foo and http://bar.jpg. I want to ...
0
votes
1answer
201 views

Issues with this sh script?

Having issues executing this sh script...i don't see anything wrong with it, does someone else see something I screwed up? echo "**************************************" echo "*** ...
0
votes
1answer
33 views

Is there a way to pass a statement via an argument in shell?

What I'm trying to achieve is to set the title of a widget when computer goes to idle: xsidle.sh echo mywidget.title = "idle" | awesome-client when i remove xsidle.sh it works flawlessly. xsidle.sh ...
1
vote
1answer
243 views

Why do I sometimes get 'sh: $'\302\211 … ': command not found' in xterm/sh?

Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: ...
1
vote
1answer
56 views

bash says '[[:' not found. what does that mean?

While running a bash script, I get this error: sh: [[: not found How can I find what where is the problem?
1
vote
3answers
103 views

Enter a string containing “!!” on a shell without it being interpretted

I'm trying to send a string that contains "!!" in it. However, every time I execute it on zsh, zsh replaces !! with the last command entered. How can I get zsh to not interpret "!!"? I have also ...
1
vote
1answer
2k views

Why does subshell not inherit exported variable (PS1)?

I am using startx to start the graphical environment. I have a very simple .xinitrc which I will add things to as I set up the environment, but for now it is as follows: catwm & # Just a basic ...
0
votes
3answers
257 views

Write pipe result to variable

I need to be able to write whether the test for a grep is either TRUE or FALSE to a variable so I can use it later For the following, if I run defaults read com.apple.Finder | grep ...
0
votes
1answer
762 views

useradd denies home directory creation Ubuntu 13.04

I'm trying to set up a git user, but am getting the error useradd: cannot create directory /srv/data/git when running this command sudo useradd \ --create-home ...
1
vote
2answers
49 views

Easiest way in Bourne shell to extract strings from a line of text?

Let's say I'm doing a grep and it returns this line: Invalid value (48) on line 3 How can I easily pull that value 48 into a variable in Bourne shell?
2
votes
3answers
2k 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 ...
4
votes
4answers
190 views

How can I find a path by providing only part of the path?

Let's say I need to find this path /<some_where_in_root>/find/this/path and the only information I have is /find/this/path. What would be the best means of locating the full directory? I ...
0
votes
1answer
144 views

service started from sh script stops when sh script

I have service named "router" that is able to receive http requests. I decided to write sh script that will periodically check health of router service. if something is wrong then it will restart it. ...
1
vote
1answer
60 views

SSH parameter help on Ubuntu Server

I have a variable setup like this: SSH_EXEC="ssh -X -o ControlPath=~/.ssh/master-$$ -o ControlPersist=60" The parameter in question is the -X, because if I then call this command within my local ...
0
votes
1answer
146 views

Automatic autorestart Firefox on close

I want firefox to restart automatically when I close it. I found this script #! /bin/sh while [ true ]; do firefox done and I put a file with that script in the /etc/init.d folder. Firefox ...
2
votes
1answer
616 views

How to compare files in different folders in Unix?

Following is the directory structure Folder1 subFolder1 File1.txt File2.txt subFolder2 File3.txt subFolder3 Folder2 subFolder1 File1.txt File2.txt ...
7
votes
3answers
31k 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 ...
0
votes
1answer
72 views

How to make an alias and work in sh for all users (not in bash)?

My question maybe is silly, but how can I make an alias so as to work in sh for all users? I know that I can put an alias, let say this one: alias ls='ls -l' in /etc/bash.bashrc so as to work in ...
1
vote
1answer
618 views

Linux: How to eval the contents of STDOUT?

Consider you have a file with some sort of terminal command. How might each line be executed? Can you pipe the output of more into an eval? %> more ./foo.txt Edit: After some help/guidance ...
0
votes
1answer
260 views

Crontab doesn't run my script Ubuntu

My script is located in /opt/restart-hlasic.sh restart-hlasic.sh contains: #!/bin/bash SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/ SERVER="XXX" ...
0
votes
1answer
152 views

Upstart event when network connectivity to a specific server is available?

Is there a way in upstart to code an event to start when network connectivity to a specific machine becomes available? Something based on a ping result would work in my case. The task being started ...
1
vote
1answer
708 views

How to force a longer `reboot` in Busybox v1.13.3?

reboot appears to make the root file system read-only almost immediately, causing a race condition with one of my processes which tries to write settings out to a file during its approx 1-2 second ...