The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
17 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 | ...
1
vote
3answers
184 views

Is there a way to open a website URL from a text file that lists 600+ URIs via a batch file?

How could I write a Windows batch script that could allow me to open an URL, with a browser—Firefox or Chrome—from a txt file containing all the URIs? The point is: I would like the script to open ...
0
votes
2answers
55 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 ...
7
votes
8answers
681 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 ...
1
vote
2answers
47 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
105 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
45 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 ...
3
votes
1answer
45 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
20 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
26 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
1answer
20 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
52 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
114 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
27 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 ...
1
vote
1answer
237 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
49 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
1k 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
44 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
84 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
24 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
18 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
117 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
31 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
30 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
81 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
60 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
382 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
913 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 ...
0
votes
0answers
16 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
94 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
54 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
2answers
71 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
275 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
997 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
457 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 ...
2
votes
1answer
1k 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
410 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
315 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
58 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?
2
votes
3answers
159 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
321 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
857 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
4answers
3k 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
249 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
157 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. ...