Tagged Questions

A shell is a command line environment that allows advanced scripting. It is provided on many (all?) operating systems based on or inspired by Unix. Notable OS's are Mac OS X, BSD, Solaris and the different flavours of Linux. Bash is such a shell created in 1987 to fix some of the problems of the ...

learn more… | top users | synonyms

0
votes
3answers
10 views

How do I change the default startup directory in Cygwin?

Whenever I start cygwin, I need to cd several levels down to the only directory that I care about when using cygwin. How can I get cygwin to start in this particular directory by default...i.e., ...
0
votes
1answer
23 views

Pipe and watch piped output?

I want to make a shell-pipe like this: producer | analyser > report.txt and watch the output of producer while it is generating data (a big log-file) for analysis. How can I do that?
0
votes
0answers
10 views

Mount truecrypt drive after user login using .profile script

I have a little script attached to .profile file. KEY="" KEY=$(zenity --entry --text "Enter password" --title "Truecrypt" --hide-text) exitCode=$? if [ $exitCode -eq 0 ]; then #OK sudo ...
0
votes
2answers
16 views

Assigning values to Variable variables

I'm having troubles with a for loop, similar to below: for VARIABLE in alpha bravo charlie; do $VARIABLE=`sed -n '/$VARIABLE/s///gp;' $FILE` done $FILE might contain something like alpha sandy ...
2
votes
2answers
11 views

Disown process from cygwin bash

There is a way to properly disown process from cygwin bash? for example i can run in background /cygdrive/c/Windows/notepad.exe & and the notepad window shows but when i close the bash using ...
0
votes
1answer
35 views

Loop until user presses 'C' in sh file

What I want is as follows: At first when user runs .sh file it displays following: Review id: You id is:XXX000YYY Do you want to change it?[Press Y to change, C to continue]: Now If user presses Y ...
0
votes
2answers
40 views

How can I limit the number of directories in my prompt?

On my Mac OS X 10.6, I have my prompt set to PS1='\[\033[01;32m\][\w\[\033[00m\]\[\033[01;34m\]$(__git_ps1 " (%s)")\033[01;32m\]]\[\033[00m\]\$ ' How can I limit the number of directories in my ...
0
votes
5answers
18 views

How to remove files this size less then 1mb?

How do i recursively remove files that are less than 1 mb in size from a directory?
2
votes
5answers
114 views

Give all files a .jpg extension

I have a directory and some of the files' extensions are in uppercase (.JPG) instead of lowercase. I want to make sure every file has .jpg as its extension. How would I do this from a shell prompt?
3
votes
1answer
42 views

How to 'source' a shell script using bash from zsh?

I am using zsh and like it very much, but work a lot with Android source which has compilation scripts that require bash to be evaluated correctly. These scripts need to be sourced prior to ...
1
vote
1answer
21 views

gnu screen: find which screen window has a given running process or variable?

I would like to find out which of my ~50 gnu screen windows has a process running with a specific variable defined in it. For example, about a week ago, I did this: id=ABC123456; ~/run_long_process ...
1
vote
2answers
86 views

equivalent “echo on” for linux?

How can I get to stdout all commands that run in bash script? That is output must contain commands output AND commands themselves. I found #!/bin/bash -x but this is not exactly the same because ...
1
vote
1answer
26 views

bash loop in an increasing sleep time?

I would like to have a while loop in bash like this: while read i do ~/bin/submit_job $i sleep N done But I would like N in sleep N to be short at the beginning, then progressively increase ...
2
votes
2answers
25 views

Read and remove lines in file, wait for new lines on end

I'm actually looking for a bash script who monitor a file, execute each new line in the file and then remove the line. When all the file is processed, the script mush wait for new lines. I searched ...
0
votes
2answers
51 views

change default shell from zsh to bash

I'm trying to change my default shell in RHEL5 from zsh to bash. I tried to the methods mentioned in this thead. By typing sudo /usr/bin/chsh -s /bin/bash, the system says sudo: /usr/bin/chsh: ...
2
votes
1answer
31 views

Create an alias - in Bash?

How can I create an alias named - in Bash? None of the following works: alias -='cd -' alias \-='cd -' alias '-'='cd -' with error: bash: alias: -=: invalid option alias: usage: alias [-p] ...
0
votes
2answers
52 views

Is it possible to add an exception with a “ls -l *”

Is it possible to do for exemple: ls -l * which print the content of all a directory. And add an exception, for exemple, test.cpp In order to print all files except the test.cpp.
0
votes
2answers
34 views

What is the correct way to alias applications in OS X through bash?

In my ~/.bashrc, I have several aliases like: alias emacs='/Applications/Aquamacs.app/Contents/MacOS/Aquamacs' alias octave='/Applications/Octave.app/Contents/Resources/bin/octave' alias ...
0
votes
0answers
31 views

Generate xml file from city list

I have a city.txt file with over 1000 lines (one city name per line) , and also a format.xml file with this code block: <ss:Row ss:Height ="22"> <ss:Cell> ...
0
votes
1answer
43 views

Why does my bash script not work? (“command not found”)

I wrote a very simple script that looks like that: $ cat pack.sh #!/bin/bash cd log rm development.log cd .. tar zcvf my_tar_ball.tar.gz * But, it doesn't work: $ pack.sh pack.sh: command not ...
4
votes
4answers
81 views

How to remove duplicated files in a directory?

I downloaded a lot of images in a directory. Downloader renamed files which already exist. I also renamed some of the files manually. a.jpg b.jpg b(2).jpg hello.jpg <-- manually renamed ...
1
vote
2answers
39 views

How can I start multiple screen sessions automatically?

I'm trying to build a command that launches screen, creates four sessions with different names, and run four different commands. I know how to do this manually: 1. screen 2. ./command1 args 3. ...
2
votes
1answer
33 views

How different shell scripts map to different OSes

New to Linux and have a few questions about shell scripting: shell C shell Bash shell Bourne shell korn shell So many "shells"! With respective to these, how do I tell which interpreters my Linux ...
2
votes
2answers
40 views

Awk responds differently based on how an empty argument is specified

I seem to have stumbled on something which is probably a bug in awk, but it could also be a bug in my understanding of bash/awk. I was trying to debug issues where the output of a python program was ...
0
votes
2answers
45 views

less emulate a TTY to preserve piped color output

When you pipe something through less, the program usually discards color codes because it's not outputting to a TTY. So you have to add --color=always to the options for it to work. ls -l ...
0
votes
2answers
31 views

.profile not running when I start a bash terminal

When I start a bash terminal, my .profile is not being executed. I do not have a ~/.bash_profile or a ~/.bash_login, so .profile is supposed to run, right? What else could be wrong?
1
vote
2answers
50 views

Bash Script: Invalid argument

Why can't I use echo $1 > /sys/class/backlight/acpi_video0/brightness in a simple bash script? It gives me the error: echo: write error: Invalid argument.
0
votes
2answers
31 views

command line alias versus .bash_profile alias

when I create this alias from the command line everything works fine alias ejecta='for I in 1 2 3; do /usr/sbin/diskutil unmountDisk disk$I;done' When the same alias is created in .bash_profile. the ...
0
votes
0answers
17 views

Starting program on boot with screen

Here is my script in init.d (Debian Linux) #! /bin/sh # /etc/init.d/blah # # Some things that run always touch /var/lock/McMyAdmin # Carry out specific functions when asked to by the system case ...
1
vote
3answers
38 views

Grep fail to ouptut to a pipe?

I'm having problems with grep filtering of make output. In particular, make target 2>&1 | grep -E --color=never "^make.*" works as expected, but the following will print no output to the ...
1
vote
2answers
41 views

Get current window number for bash prompt

I want to replace status bar with bash prompt displaying window number like ①. How can I get current window number in the shell? There's TMUX_PANE env variable, unfortunately no TMUX_WINDOW. The ...
0
votes
2answers
45 views

See what a user did with date/time?

I am trying to see what a specific linux user on my system did, and I looked at bash_history, but it doesn't have any dates. Is there a method I can look at that would give me dates/time?
0
votes
0answers
37 views

Add a line to a file section unless it exists [migrated]

I have a file that looks like this: ... %ldirs (list of line-separated directories) ... With a shell script, I need to add a directory to the list in that file, but only if that directory is not ...
0
votes
3answers
87 views

Can I create a configuration file for a shell script?

Is it possible to create a .sh shell or .command file with a configuration file? I need to backup websites via Terminal and be able to put some data to configuration files, and have the shell execute ...
0
votes
1answer
16 views

How can I make zshell skip confirming substitutions?

If I run the following commands in bash: mkdir foo cd !$ The second command will be interpreted as cd foo and executed. In zshell (at least with my current configuration), it will make the ...
3
votes
4answers
271 views

`alias rm=“rm -i”` considered harmful?

I have read some time ago (can't find the reference) that using such an alias as alias rm="rm -i" was very bad. Is there historical evidence or common sense explanation for that fact? I would ...
2
votes
1answer
21 views

command-line utility to record from microphone

I am looking for command-line utility that monitors the microphone, and if you start to speak, writes the file. Recording period should be adjusted. Solution is: sox -t alsa default recording.wav ...
0
votes
1answer
27 views

Find modified files from rsync backup script

I'm using rsync on my Ububtu Linux server to take a time machine like backup of the system. Every hour, a cronjob runs the following script (partial excerpt): rsync -a --link-dest=/backup/current ...
2
votes
0answers
30 views

Is there a way of using ctrl-r after typing part of command in bash?

In bash the ctrl-r command is very useful, I type ctrl-r whatever and it searchs my history for commands containing the word whatever. But if I type whatever and realize that I would like search that ...
0
votes
2answers
62 views

How to install ComixCursors (or other x-cursor themes) in Ubuntu via shell script?

This question has two parts: How to install an x-cursor-theme in Ubuntu via a bash shell script. The cursor theme is not expected to be in the repositories. How to actually make the new theme become ...
0
votes
0answers
70 views

bash: redirect the stderr/stdout of a running process?

I have a running process running in a bash terminal that is printing some prompt, and I would like to send it to the background with the stderr/stdout prompt that is printing either redirected to ...
0
votes
1answer
89 views

Arch Linux: colors from terminal in bash script?

In addition to ArchLinux - yaourt: save updatelog? With tee I am able to get the output at a file and at the terminal at the same time. But when I execute yaourt -Syu | tee yaourt.log in a bash file ...
0
votes
0answers
41 views

cygwin - bash can't find file depending on arguments

If I type bash -i release_script.sh it starts processing the script If I type bash --login -i release_script.sh I get the error: bash: release_script.sh: No such file or directory I don't ...
0
votes
1answer
26 views

Why does this bash prompt sometimes keep part of previous commands when scrolling history?

My bash prompt, which I'll admit to have stolen from a few places and cobbled together, will sometimes add part of previous commands to its length when scrolling the bash history with up/down arrows. ...
2
votes
1answer
25 views

can I use wrap a command inside a history-aware script?

Suppose I have a command line interface tool that doesn't have any notion of 'history'. Would it be possible to write a small script that merely does readlines and forwards them to the tool, but that ...
2
votes
5answers
159 views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
3
votes
3answers
85 views

Does rm -f follow symbolic links?

I have a directory like this: $ ls -l total 899166 drwxr-xr-x 12 me scicomp 324 Jan 24 13:47 data -rw-r--r-- 1 me scicomp 84188 Jan 24 13:47 lod-thin-1.000000-0.010000-0.030000.rda ...
0
votes
0answers
19 views

How to run sun virtualbox or qemu using BASH to load one operating system full-screen to the left display where i have one display reserved?

I have a complex case, i do not know how i will solve it but maybe you guys must know it :") I need to organize a solution which will allow me to run dual head, seam-less mode, everything command and ...
0
votes
3answers
76 views

Process plain text data

I've this plain text file that I need to be automatically examined and results written in another plain text file. Note that I'll use plain text and CSV interchangeably, since CSVs are plain text ...
1
vote
2answers
33 views

Brace expansion substitution?

I've made a small bash script to automatically split my two monitors with imagemagick when I take a screenshot. #! /bin/bash convert "$1" -crop 1024x600+0+0 +repage "${1//.png/}-left.png" convert ...

1 2 3 4 5 34