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

learn more… | top users | synonyms

3
votes
3answers
2k views

What does $@ mean as a bash script function parameter

What does $@ mean as a bash script function parameter? Example: function foo() { echo "$@" 1>&2; }
0
votes
1answer
1k views

Is there anything like iTerm2 + Byobu on Windows?

I'm stuck running Windows as my primary OS at work. I'm trying hard to find a good console environment, but falling short. I'd like to have iTerm2 + Byobu. So far I'm using conEmu with the cygwin ...
0
votes
2answers
49 views

View network locations from Debian shell

I'm trying to see a list of all devices on the network from the shell in debian. The same list you get by typing 'Network' into an explorer window on Windows. Seems like it should be an easy thing to ...
2
votes
0answers
130 views

Downloading and building O3D

I'm trying to get a program called O3D into my computer by following the instructions on O3D's wiki. I tried to download the project to my directory but the prompt gave me this answer: gclient is ...
2
votes
4answers
693 views

Add a display to let user wait in bash

I am looking for a pretty stupid piece of code for bash that will show a kind of "please wait" rolling display, with the characters : - \ | / The first problem is that I don't know the name of this ...
1
vote
1answer
692 views

Sending Linux commands over serial connection to an Android device

I have a question about being able to send Linux commands over a serial connection to an Android device. I have heard of PuTTY and tried to use it, but I am ultimately lost with it. I was in the ...
1
vote
1answer
52 views

Why changing directory with `/../` works?

Change directory: $ pwd /usr $ cd bin && pwd /usr/bin With .., same outcome: $ pwd /usr $ cd bin/../bin && pwd /usr/bin But why? Why the shell is not throwing an error?
0
votes
2answers
717 views

Shell function in .bashrc is not recognized

I know this must be something silly but somehow I am stuck trying to create a shortcut (alias) for a shell function. Here is my exact .bash_profile: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source ...
1
vote
5answers
25k views

How to test if a variable is equal to a number in shell

I have this shell script that isn't working. Input: Server_Name=1 if [ $Server_Name=1 ]; then echo Server Name is 1 else echo Server Name is not 1 fi Output: Server Name is 1 But, if i ...
1
vote
0answers
325 views

Error while remount a partition read only

I have a rooted HTC and need to create a custom file in /system/xbin. I execute a mount command (for read-write permission on /system), create the file, remount /system in readonly and after that my ...
0
votes
1answer
37 views

Shell command ${PWD/\/$upto\/*//$upto} not understood

I saw a shell function to change dir up to $upto. upto() { cd "${PWD/\/$upto\/*//$upto}" } But I don't understand "${PWD/\/$upto\/*//$upto}". Could any one kindly explain? The function was ...
1
vote
2answers
217 views

How can I replace icons of an application's executable?

I have an application whose executable contains some default icon. Now, I know I can use a shortcut with whatever icon I want, but what I'm looking to do is change the icon without the executable ...
4
votes
1answer
2k views

How to generate a PDF from a series of images?

I have a series of images (a scanned book, actually) that I want to make into a PDF in A4 format. Why I'm doing this: I'm helping a less computer savvy person in a different country to get a printed ...
0
votes
2answers
738 views

How to restrict grep to search only below a token of a column?

How can I use grep to search only the values of a column below a token? For example in the following CSV file: A B C 1 4 5 2 3 0 1 3 6 ...how can I get only ...
0
votes
1answer
291 views

Find number in string and replace it

I wrote C++ code and now I want to replace the number in a string by using shell scripts. The part that needs to be replaced: if (random<=90) How I can change the 90 from a shell script? I ...
0
votes
2answers
214 views

sum numbers in different lines in shell

i have 8000 lines similar to this <Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+924100.0ns" timeLastTxPacket="+199984927558.0ns" timeLastRxPacket="+199675473275.0ns" ...
4
votes
1answer
102 views

Shell history support that doesn't suck?

When I use multiple terminal sessions at once, bash only persists the commands from one of them. Then later when I try to do a reverse command search, the command I want is not going to come up, ...
1
vote
1answer
583 views

Shell script to show online users

I know it's an amateur question. I need to write a Bash shell script which count how many users are online at the moment on the SSH server. I need to ignore multiple logins and show the username and ...
1
vote
1answer
46 views

$(shell [foo]) in windows

I've got a makefile (a file called 'Makefile' which is run by cmake I believe), and most of the 'sample' ones I can see are just one line (and the rest appear to be stuff I don't 'yet' understand and ...
1
vote
2answers
896 views

Filling up the hard drive until certain amount of space is left?

I'm doing some testing of a product on Apple and Android devices. I'd like a script that will fill up the devices hard drive until 100KB space is left on the drive it's runs against to. Also in linux ...
56
votes
3answers
30k views

scp between two remote hosts from my (third) pc

I have two remote hosts. host1-> 10.3.0.1 host2-> 10.3.0.2 Both run an ssh server. The ssh server listens on port 22 in host1 and on port 6969 in host2. Now, using my local machine, I need to copy ...
2
votes
1answer
447 views

When is .zprofile file read?

I am using .zprofile to set up some stuff, and I assume it is evaluated everytime I log in to given user. Am I correct?
0
votes
1answer
35 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 ...
0
votes
2answers
837 views

Using Wget / shell to download a file from outside of the web root

I am trying to download the httpd.conf file so that I can edit my Apache configuration. I can get access to the directory it is in via the shell (I have root access), but all of the examples on how ...
1
vote
1answer
82 views

Why does bash sometimes show an underlined u?

Sometimes, when I am typing really fast in bash, I accidentally do something and I get an underlined u diplayed at the prompt. After that, bash behaves strangely (I'm sorry, I can't remember what it ...
2
votes
0answers
510 views

tmux in zsh with vi mode, toggle cursor shape between normal and insert mode

(note: I wrote this question on stackoverflow, but got flagged as offtopic, so I'm re-writing it here) Here's what I want: Consistent behavior (as much as possible) between Vim, MacVim, zsh with ...
0
votes
1answer
51 views

How to reference previous parameter in interactive bash shell?

I'm trying to do something like: mv doc1 $1.html #equivalent to mv doc1 doc1.html but the problem here is that, because I'm in an interactive shell, $1 refers to the first parameter passed to ...
0
votes
2answers
177 views

Is there a way to create a process which can be killed by anyone in Linux?

For example, I would like to start running a process in the background SECRETLY on a Ubuntu server , but whenever anybody except me logins to the server, the process must be killed by that user. Is it ...
2
votes
1answer
487 views

“which rails” works.. but “rails --version” doesn't.. how come?

This may be related to what i did here.. but when I type the command which rails I get /usr/bin/rails but when i type rails --version I get: ...
1
vote
2answers
288 views

How do I launch a command file (e.g. *.sh) in a separate shell interaction utility (e.g. iTerm2) on my user's login?

iTerm2 is an awesome utility and makes my interaction w/ the command line much easier. There are a lot of update commands I run on a daily basis, and thought it would be amazing if those could be ...
0
votes
4answers
1k views

Batch file rename script swapping substrings in filename?

I have a group of files named like title_december_word1_word2.png and want to iterate through the directory and swap word1 and word2 within each file. i.e. go from "button_december_state_pressed.png" ...
1
vote
1answer
110 views

Pre-compiled command line input in zsh

I recently set up a ubuntu 12.04 64 bit machine. I use tmux with many open windows, all of them use zsh as shell, some of them through a chroot environment that uses the same home folder of the normal ...
1
vote
1answer
102 views

PATH not set in GNU Screen, OS X 10.9

I'm not a regular user of screen but every few weeks I use for some delicate tasks. However yesterday when starting I was unable to execute any command (ls, ssh, mkdir), quick debugging revealed that ...
1
vote
1answer
323 views

How to prefix every command in shell with “sg - grp -c”?

I am using bash shell. I want to run all commands of a specific user to be run as a specific group command in the shell. How can I do it? Can anything be can be done in ~/.bashrc ?
2
votes
1answer
3k views

SSH Tunnel for restricted user w/ PuTTY and no shell

so I have been using SSH tunnels to restrict access to internal sites or portions of public sites for a while now, and since only admins had SSH access at all I've been using standard non-root/sudo ...
14
votes
3answers
22k views

Linux : To monitor a Service and restart if stopped?

Actually I'm not so sure whether i should use Shell Scripts, or if there some ways already. But whatever approach we use, i would like to keep a Service running all the time. Let's say iptables as an ...
1
vote
1answer
586 views

Can I detect the presence of a second display in a shell script or Conky config?

I want to modify my conky placement depending on whether I'm working with my laptop in my lap (one screen) or have it at my desk attached to a larger monitor (dual display). The problem is that I ...
0
votes
1answer
387 views

How do I access this environment variable in the windows git bash shell

I am trying to configure my windows portable git bash shell. When I execute env I get: ANT_HOME=C:\Program Files\WinAnt PORTABLEAPPS.COMVIDEOS:FORWARDSLASH=H:/Documents/Videos ...
2
votes
0answers
532 views

Using the msysgit shell in Emacs for windows

I am relativley new to Emacs and am trying to setup emacs, to allow the following command to open the msysgit shell. M-x bash-shell I have added following snippet to my init.el. (defun bash-shell ...
1
vote
1answer
206 views

What is the difference between “su -” and “bash -l”?

What's the difference between su - and bash -l? I have this problem: :/etc/profile.d # su - Cannot open display "default display" Directory: /root Thu Nov 28 11:23:57 CET 2013 Now I try to find ...
3
votes
1answer
251 views

Why does `${$(pwd)}` output current working directory in zsh?

In zsh, ${$(pwd)} output the current directory. However, if I run echo ${/path/to/somewhere}, it just shows an empty line. Why does this happen? Thanks!
1
vote
2answers
1k views

extract characters between first and second underscores of filenames and count such files in linux folder

I would like to extract characters between first and second underscores of filenames in a folder and count such type of files present in it. The folder contains files in a particular format such as : ...
0
votes
2answers
159 views

Is there a standard command-line tool to do a hostname lookup?

I am in the shell and I want to know the corresponding IP address(es) for a hostname. I know I could get it through Perl, PHP, Python or a number of other scripting languages (probably even awk!), ...
1
vote
1answer
1k views

Use “>>” Redirection Operator for Non-Existent File In tcsh/csh

I'm writing tcsh scripts and I would like to append to a log file, but if the log file doesn't exist before appending to it, I get an error (reproduced below). In bash the file gets created if it ...
0
votes
2answers
636 views

Mac script to copy files (execute by clicking on icon)

I have a script on my Mac Desktop: myProg.command or myProg.sh, the content is: cp "foo/foo.txt" "bar/foo.txt" The script is set as executable. The directories Desktop/foo, Desktop/bar and the ...
4
votes
3answers
13k views

Execute a command stored in a variable

I have a command stored in a variable. Let's pretend the variable $i has the value: cat -nT index.php |grep 'someregex' When I try to execute the above variable by typing $i it fails because the ...
31
votes
5answers
3k views

Deleting millions of files

I had a dir fill up with millions of gif images. Too many for rm command. I have been trying the find command like this: find . -name "*.gif" -print0 | xargs -0 rm Problem is, it bogs down my ...
0
votes
1answer
141 views

How to create my own vpn service on linux shell?

My company has a private linux server, and I'm just a user of this server, my connection to it is via putty or nc. Is there anyway to install a private VPN on it? our server is connected to the ...
0
votes
2answers
436 views

Loop through a list of urls in a text file

I have a list of URL's that looks like the following: http://www.youtube.com/watch?v=QVgFCCQWBOs http://www.youtube.com/watch?v=8TrMhR7ZpBk http://www.youtube.com/watch?v=8ctAvtBJB3s ...
0
votes
1answer
2k views

Specifying an alternate shell with rsync

I'm using rsync to sync up files between two computers. On one machine, my default shell is set to fish, which breaks rsync ("protocol version mismatch -- is your shell clean?"). Is there a way to ...