A shell is software that lets users interact with the operating system, usually by typing at a command-line.

learn more… | top users | synonyms

1
vote
1answer
26 views

Command not working on shell but working on prompt

I am a newbie to Linux Shell Script. I want to change the IP address by Linux Shell Script and called by a PHP web application. I have finished my PHP web application and the shell script. Before ...
3
votes
2answers
303 views

How to execute a second condition if the first condition is true in Linux shell scripting

I have an if condition. If that condition is true then one script will be run and after that I need to check another condition. How can I do that using an if statement or something else? For ...
0
votes
1answer
14 views

Running the output of `ssh-agent` in fish; what does `setenv` do?

When I want to start (or restart) ssh-agent, it gives me a few commands that I should run by doing eval $(ssh-agent). Of course this fails for fish, since it gives syntax for bash or csh. The ...
-3
votes
1answer
30 views

Automatic start of processes in linux server if error found

please check below script . here "sanity" and "start" are the scripts . It will work ? please suggest > #!bin/bash > DATE=`date +%Y%m%d` > touch opt/logs_$DATE > sanity >> ...
54
votes
4answers
89k views

How to make new file permission inherit from the parent directory?

I have a directory called data. Then I am running a script under the user id 'robot'. robot writes to the data directory and update files inside. The idea is data is open for both me and robot to ...
1
vote
0answers
4 views

How to read contents of ATSAM3X8E chip on Arduino Due Board in Mac OS X

I have two Arduino Due boards with some programming that has since been lost. I need to back up the contents before replacing the program. I’ve been playing around with another Arduino Due before I ...
0
votes
3answers
39 views

Loop inside EOF - UNIX SCRIPTING

I am writing a script to automatic start up of an application whenever we found error in logs. so #/bin/bash if [ grep -c 'error' logs -eq 0 ] ;then exit else start <<EOF ## start is a ...
1
vote
2answers
32 views

“read” works as expected in ZSH but behaves differently when using any other shell

I’ve written a short while-do cycle but I found it working strange with different shells. That's it: find "`pwd`" -type d | while read -r D; do ls ${D}; done When I start it using zsh, all goes ...
5
votes
1answer
63 views

Why does rsync read .bashrc and not .profile?

rsync is a non-interactive program that logs into other machines. It shouldn't need the init file for an interactive shell session, and it should absolutely need the init file for a login shell. Or so ...
-2
votes
1answer
25 views

using find and delete files/folder - with the exception of 1 folder - challenging

i want to use find and delete everything with the exception of one folder if found. e.g. [oracle@SJOAM test]$ ls -l total 4 -rw-r--r--. 1 oracle oinstall 0 Sep 2 02:05 a -rw-r--r--. 1 oracle ...
0
votes
1answer
99 views

How to open git for windows shell inside a tab on ConsoleZ

I have used git bash 1.9.5 from https://git-scm.com/download/win on ConsoleZ as shell and have no problem on open him inside a tab. But, with the new Git for windows 2.4.5.1 RC4, it open always in a ...
0
votes
4answers
577 views

How do I close stdin in a shell script?

I have a misbehaving program that I need to call from my script. It exits as soon as it sees something on stdin. Is there a way to close stdin?
169
votes
20answers
89k views

How to execute a command whenever a file changes?

I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I'm finished working with ...
15
votes
8answers
25k views

Make ls sort by file type (then name)

By default the ls command sorts just by filename, but I want directories to appear before other file types. I might even want files to be sorted by extension, like the way Windows explorer sorts by ...
58
votes
5answers
112k views

If I know the PID number of a process, how can I get its name?

If I have the PID number for a process (on a UNIX machine), how can I find out the name of its associated process? What do I have to do?
8
votes
2answers
17k views

Bash not loading '.profile' in new session on Linux

I'm setting up a new Linux machine I got from our IT dept, and noticed .profile is not loaded when I start a new terminal session. The current shell is Bash, though I changed it from the default sh it ...
0
votes
1answer
25 views

Bash script to create a folder structure

I'm trying to write a Bash script to automate a recurring task, namely the creation of a structure of folders, where some of them should be numbered (To be more specific, this is meant to archive some ...
9
votes
4answers
3k views

re-use '~/.profile` for Fish?

(I'm talking about the shell Fish, esp. Fish's Fish.) For Bash/ZSH, I had ~/.profile with some exports, aliases and other stuff. I don't want to have a separate config for environment variables for ...
0
votes
2answers
91 views

Log in using SSH without password

On my server, I've got openssh-server and a special account without password. I'm creating a shell script, that must be used without user input. For example $(ssh dummyUser@dummy.com) I need script ...
1
vote
1answer
17 views

Upstart: What is the first tracked PID w/o expect, but with script AND exec?

I have some Upstart configs used to start some foreground and blocking processes to run in the background as some kind of "daemons", especially those processes do not fork in any case. What I want is ...
0
votes
0answers
9 views

Running SGE array job

I am working on SGE and I want to submit an array job for 10 files. For the time being to keep it simple I want to use only 2 commands in the script for each input files So let's say I have 10 input ...
-2
votes
1answer
37 views

bash: Loop over lines of a file

Here is my script: #! /bin/sh for line in $(cat list); do echo "[$line]: Getting my workers list.."; var=$line-"worker1"; echo "$var" >> "hostlistworkers.txt" ...
1
vote
0answers
13 views

How to set output of terminal to external VGA display

I have laptop with broken screen and external monitor that i can connect to laptop via VGA port. Is there any way how to set output of shell(I have no GUI on installed debian) to VGA monitor? I can ...
0
votes
0answers
16 views

How can I get new messages in thunderbird via linux terminal?

I am trying to find a way of getting new messages from Mozilla Thunderbird without opening it.
0
votes
1answer
46 views

git rebase --interactive throws an error

I'm relatively new to git. Could anyone, please, help running git rebase --interactive properly? It throws an error when I try to execute it. Note: I don't want to uninstall Xcode unless it's ...
2
votes
2answers
78 views

Run tcsh with arbitrary startup script

I want to create a new instance of tcsh and source an arbitrary script, all in one step. The problem is that when I use the -c option, the shell instance closes as soon as the script is complete. ...
1
vote
3answers
32 views

How to scp-and-ssh with specifying host twice?

I frequently do this kind of thing: scp somefile me@host:/some/path ssh me@host Typing out me@host twice can be irksome. We (or at least bash) can grab that last argument with !:$, but that ...
-1
votes
1answer
43 views

Enter shell script output in a Xml file

<property> <name>mapred.tasktracker.map.tasks.maximum</name> <value>2</value> <description>The maximum number of map tasks that will be run simultaneously ...
3
votes
3answers
11k views

Using backslash to escape characters in cmd.exe (runas command as example)

I see that the caret is the documented escape character. But, I have an example showing that for the double quote character, ^ doesn't work and you have to use \ C:\>runas /user:Administrator ...
0
votes
1answer
27 views

Why awk printing wrong string into the output file?

I'm trying to read file with awk and write the output in a new file. Content file sample: DATE_Login|09:01:20.507|2015-08-13|TIME_Session|00:32:32|MX|w32 ...
-3
votes
0answers
37 views

How to write a shell script output to an XML file

I want to write a Shell script output inside a value in a XML File as shown in the following example: Assuming initially the line inside the XML looked like this (with number 4 inside) ...
1
vote
1answer
38 views

Incorrect output of history command of ssh. How to read the timestamp info correctly

I set the HISTTIMEFORMAT variable to store the timestamp info .bash_history file. I am able to display the history properly if I use interactive shell. But, when I run history command to display ...
4
votes
2answers
3k views

UTF-8 locale portability (and ssh)

I spend a lot of my time sshed into various machines, all of which are different (some are embedded, some run Linux, some run BSD, &c.). On my own local machines, however, i use OS X, which of ...
149
votes
14answers
128k views

How do I detach a process from Terminal, entirely?

I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a ...
1
vote
2answers
1k views

starting mongodb from a bash shell script

I am trying to start a mongodb using a cronjob+shell-script combo. In the shell, mongoDB starts when I enter $ mongod, however my executable shell script fails with mongod: command not found. I ...
20
votes
9answers
45k views

How to resume CUPS printer from command line?

I have printer in CUPS that due to driver problems (HP 1010) from time to time goes into pause. I would like to write a shell script that will execute once per hour to resume a printer in CUPS. But ...
0
votes
3answers
24 views

formatting output in bash shell to remove special characters - linux

I am issuing the command below against a logfile grep "Oracle Audit" /var/adm/messages | awk '{print $6}' How do I format the below output Audit[9460]: Audit[10507]: Audit[10507]: Audit[10507]: ...
0
votes
2answers
299 views

Android ADB Shell sendevent Not Working

I want to simulate pressing the power button on a rooted Samsung Galaxy Tab 2 GT-P5100 running Android 4.0.4 using the ADB shell. To do this I changed the relevant permissions using: adb shell su ...
0
votes
1answer
33 views

Change default shell on MSYS2

I want to change MSYS2's default shell from bash to zsh. I've tried chsh - not available in MSYS2. Editing /etc/passwd does nothing. It seems to be ignored. I took a look at the batch scripts in ...
1
vote
2answers
4k views

Mac Terminal showing bash instead of my username

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing ...
2
votes
1answer
259 views

Error “Insecure world writable dir /Volumes/BOOTCAMP in path, mode 040777”

I tried the answer sudo chmod go-w in my /Volumes/BOOTCAMP but I'm still getting the warning It says Insecure world writable dir /Volumes/BOOTCAMP in PATH, mode 040777 And when I echo $PATH ...
0
votes
3answers
43 views

/etc/shadow and /etc/passwd privilege - why is it writable

sghk1> id uid=0(root) gid=0(root) sghk1> ls -l /etc/shadow -r-------- 1 root sys 4045 Aug 24 15:52 /etc/shadow sghk1> ls -l /usr/bin/passwd -r-sr-sr-x 1 root sys ...
102
votes
3answers
91k views

How do I change my default shell on a AWS instance?

I want to change my shell from the default bash shell to zsh on my Amazon EC2 instances. How do I go about doing it? Thanks!
0
votes
0answers
21 views

Undo command Linux “rm” [duplicate]

Please, I have used rm * in a script shell, it deleted all my files? (a typo) Is there a solution to recover these files ?
0
votes
2answers
2k views

How to store results of multiple sql queries in shell variables in Bash?

I need to store in array the results retrieved from the database. So far this is basically what I'm trying with no success. Myarray=$(echo "SELECT A, B, C FROM table_a" | mysql database -u $user ...
1
vote
1answer
22 views

How to run overdue at jobs

Sometimes I have at jobs overdue after system-suspend that don't run after waking up. How can I tell atd to run them? I tried atd -s or atrun but I guess that isn't meant for this as it doesn't run ...
3
votes
3answers
1k views

How to uninstall preinstalled UNIX software on Mac OS X?

I want to uninstall some applications shipped with Mac OS that are a part of UNIX. My plan is to uninstall most of the default stuff to install it via Macports. That would make upgrading, ...
7
votes
3answers
6k views

How do I set my shell in Mac OS X?

I know I can set "Shells open with" in the Terminal preferences, but I'm curious if there's any system-wide way of setting this (similar to updating /etc/passwd in some Unixes).
0
votes
1answer
3k views

ksh Auto-Completion PuTTY Configuration

I'm having a bit of a problem configuring my PuTTY client to work with the auto-completion feature in the ksh shell. I do a listing on the root with the directories /home and /homeroot and it returns ...
0
votes
2answers
38 views

FFmpeg : mp4 and multiple srt into mkv

I have a couple of srt subtitle tracks for an mp4 video. How do I make them into mkv using ffmpeg/avconv? I would like to use space efficiently. Performing conversion on Darwin v13. I will be ...