The tag has no wiki summary.

learn more… | top users | synonyms

96
votes
4answers
98k 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 ...
17
votes
3answers
31k 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 $
10
votes
3answers
2k views

How is install -c different from cp

What is the difference between install -c and cp? Most installations tend to use install -c, but from the man page it doesn't sound like it does anything different than cp (except maybe set ...
10
votes
2answers
27k views

What exactly is the sh command?

I can't figure out what the sh command is? http://unixhelp.ed.ac.uk/CGI/man-cgi?sh Does it execute a file? like in tomcat: sh /usr/local/tomcat/bin/shutdown.sh Sorry, just confused.
9
votes
2answers
3k views

Comments in a multi-line bash command

This single-command BASH script file is difficult to understand, so I want to write a comment for each of the actions: grep -R "%" values* \ | sed -e "s/%/\n%/" \ | grep "%" \ | grep -v " % " \ | ...
8
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 ...
8
votes
2answers
834 views

Making bash TAB completion more like cmd.exe [duplicate]

I wondered if theres a way to do rotational style completion in bash similar to the behavoir on cmd.exe, I've found it speeds me up in regard to entering commands
5
votes
3answers
144 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?
4
votes
4answers
192 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 ...
4
votes
4answers
3k views

How do I start in bash when ssh'ing into my server?

I have a hosted Debian server. When I log in via ssh, I'm greeted with a sh environment. How do I change it so I start in a bash environment?
4
votes
3answers
10k 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.
4
votes
2answers
523 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 ...
4
votes
2answers
220 views

shell dotfiles and *rcs: what's a sane setup?

A bash user will eventually end up with .bashrc, .bash_profile, .profile, and maybe some more. Now, each file gets loaded unders particular situations, and it all leads to confusion and frustration. ...
3
votes
1answer
440 views

Forcibly break a for loop in sh

If I run a for loop on the command line in sh, and I press control-C, it usually cancels the current running process, so I need to hold ^C until the shell itself catches it and breaks the loop. Is ...
3
votes
1answer
783 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 ...
2
votes
3answers
2k views

How can cat/print a file except the last 2 lines?

How can get a file, except the last (for instance) 2 lines, with standard or GNU shell tools? (bash, tail, cat and so on.)
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 ...
2
votes
2answers
649 views

How run sudo -s after ssh login

My Step By Step: On myserver.com i paste line "sudo -s" to file "~/.bashrc" in home directory for "mylogin" SSH Login to mylogin@myserver.com After login: root@myserver.com:~$ But, press cntrl+D ...
2
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 ...
2
votes
2answers
490 views

Is there a way to remove root requirements for a specific command in linux? If yes, how so?

I'm using Ubuntu 12.04 LTS, and I'm trying to make it so that the specific command dhclient doesn't require root privileges. I've done some research that leads me to believe I could unlock an "su" ...
2
votes
2answers
456 views

Allow any user/password entry in ssh

I want to setup ssh so that one can login with any username or password and be accepted. If they chose a username and password of an actual user on the system they will successfully login and use ssh ...
2
votes
1answer
27 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, ...
2
votes
1answer
632 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 ...
2
votes
2answers
250 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?
2
votes
1answer
395 views

How to set-up date for cron weekly backup?

I'm writing a command for cron to do automatic backups for my flashdrive. I use tar ... -N <some date> to make the backup. The issue is how to write the command which gives me the right date. ...
2
votes
1answer
424 views

sh on Lion can't cd into folders with implicit paths (causing make to fail constantly)

I've had a problem with my OSX 10.7 Lion install for some time and I finally took some time to investigate. The issue is that when running make, I always get an error of the form: /bin/sh: line 0: ...
2
votes
2answers
201 views

Screen does not appear in list when using sudo

While under root user (printed by whoami), execution of sh -c "screen -d -m -S testscreen sh -c \"echo asd; echo qwe\"" creates a screen with two lines output, which can be reattached via screen -r ...
2
votes
1answer
967 views

execvp exec format error for shell script on Red Hat Enterprise Linux 6

We have two RHEL 6 systems that are running identical versions of the kernel and glibc (glibc–2.12–1.90.el6_3.6). According to the POSIX standard and the Linux man pages, if the kernel determines that ...
2
votes
2answers
567 views

Log Files from bash script output

I have a script that runs (this works fine). I'd like to produce logfiles from its output and still show it on screen. I have this command that creates three files from this blog: ((./fk.sh ...
1
vote
3answers
818 views

Renaming a file from myFile.sh to myFile.bash?

PART 1 Ok so i'm using Mac and I started out with a file called... Example: myFile.sh In Terminal I ran this file in its directory by typing... bash myFile.sh That works perfectly, but then I did ...
1
vote
5answers
1k views

How to run .sh file

I am using Ubuntu and just downloaded the jmonkey game engine. Everything appears to be in a single .sh file. I am not really sure how I am supposed to run this. http://jmonkeyengine.com/
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
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 ...
1
vote
3answers
416 views

How to find out environment variables set after logging into a shell session

How can I find out the environment variables set after logging into a shell session? My two dummy solutions have been so far as follows: _VariableName1="VarValue1";export _VariableName1; ...
1
vote
1answer
2k views

Run SH Commands in Background

I have a bunch of scripts that I need to run to start up a couple Node.js scripts and Mongo, among a couple other things. I'd like to create an SH script that I could run to start ALL of these at ...
1
vote
2answers
3k views

What happens to the environment when you run “su -c”?

What happens to the environment when you run "su -c"? The reason I ask, is this mysterious behavior: bash$ which firefox /usr/local/bin/firefox bash$ su - user -c "echo $PATH" ...
1
vote
1answer
55 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 ...
1
vote
1answer
502 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) ...
1
vote
1answer
620 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 ...
1
vote
1answer
25 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
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 ...
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 ...
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 ...
1
vote
1answer
560 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
152 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 ...
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?
1
vote
1answer
608 views

how to read data from a file in shell script

I have two shell script files test1.sh and test2.sh . I have another file called translogs.txt. Now I need to copy the values of two variables in test1.sh to translog.txt and the same variables need ...
1
vote
1answer
1k views

sh alias: command not found

I have written a very simple script like this: function apply_to_dev { echo "Applying scripts to DEV..." alias ISQL="isql -Uuser -Ppwd -SDEV -DDATA -I ~/bin/interfaces" shopt -s nullglob ...
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 ...