Bash is a free shell for Unix-like operating systems, from the GNU Project

learn more… | top users | synonyms

1
vote
4answers
912 views

(bash) Grep question - how to grep for a line that has the same number you both need and don't need

This isn't at all easy to explain but easy to just show. I have lines in a file such as: 100Dollars 3 IP 200Dollars 3 IP 300Dollars ...
1
vote
1answer
251 views

bash does not recognize alt+backspace command

I use bash and alt+backspace key to delete a word at a time. This works nicely, but for some reason, it stops working after a while. It seems as though it does not recognize the alt key, and simply ...
5
votes
5answers
5k views

Bash color shell on Mac?

How can you make a bash shell list executable files in a different color than non-executable files? I've tried editing ~/.bashrc to contain the following line (it's otherwise empty): ...
4
votes
3answers
6k views

Bash script to keep last x number of files and delete the rest

I have this bash script which nicely backs up my database on a cron schedule: #!/bin/sh PT_MYSQLDUMPPATH=/usr/bin PT_HOMEPATH=/home/philosop PT_TOOLPATH=$PT_HOMEPATH/philosophy-tools ...
1
vote
1answer
971 views

rm - command not found

I recently wanted to use the rm command in Terminal on my Mac. To my surprise, it just reponds with: -bash: rm: command not found I can use mv, cp, cd, ls etc. However rm somehow doesn't work. I ...
7
votes
5answers
3k views

How to count total number of lines of found files?

I'm running a find . -name pattern to find some files, and I'd like to elegantly get the total number of lines in these files. How can I achieve that?
26
votes
9answers
3k views

Any shortcut for “cd ..”?

Is there any shortcut for cd ..?
1
vote
1answer
145 views

How can I automate or script daily downloads for any new anti- virus databases, and then have the program scan my drive?

(I know there are much better softwares out there for the Mac so please don't go there! The politics of this company dictate which Anti virus we have to use) Anyway without any further wait: ...
2
votes
2answers
1k views

BASH: find duplicate files (MAC/LINUX compatible)

I am looking for a bash script which is compatible with Mac, to find duplicate files in a directory.
2
votes
2answers
730 views

Bash: number of seconds till midnight of current day

How do I find the number of seconds till midnight of current day?
2
votes
1answer
1k views

How to tee to stderr? (multiple sinks in one pipeline)

some_source | (tee /dev/stderr | sink_1) 2>&1 | sink_2 Seems to fail. How to do it right without of any temporaries?
0
votes
1answer
284 views

error propagation not working in bash

I have a script which goes as below... some function definitions on top and one of them is... function err_out { trap 'echo "ERROR in $STEP function. EXITING!";exit 1' ERR #some more ...
2
votes
3answers
350 views

Why doesn't the shebang cause a program to fork like it should?

I always declare the shebang line #!/bin/bash in my shell script. Recently, when I called a script that contains an exit call, it killed my terminal. It usually kills the forked process and returned ...
10
votes
5answers
2k views

How to run sed on over 10 million files in a directory?

I have a directory that has 10144911 files in it. So far I've tried the following: for f in ls; do sed -i -e 's/blah/blee/g' $f; done Crashed my shell, the ls is in a tilda but i can't figure out ...
9
votes
3answers
3k views

How to cd to a directory that contains a space in its name?

I have a directory called "Reader 0.5" in my Desktop on Mac Os X. When to access the directory in terminal, I am using below code: cd /Users/niho/Desktop/Reader 0.5 but it throws: No such file or ...
3
votes
1answer
444 views

gnome-terminal/bash: How to cancel inserted commands that will be executed later?

$ execute_some_long_command <command is executing> <Accidently press middle button that inserts bunch of garbage (including, for example, `rm -Rf ~/*`) into console> How to let ...
0
votes
1answer
909 views

Change Mac “Ask for password after screensaver” delay

How can I change my Mac OS X Snow Leopard "Ask for password after screensaver" delay? I've tried: defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 3600 but won't work. I ...
5
votes
4answers
7k views

echo newline character not working in bash

I have bash script which has lots of echo statements and also I aliased echo to echo -e both in .bash_profile and .bashrc, so that new lines are printed properly for a statement like echo ...
0
votes
1answer
374 views

How can I create a no-login account in OS X that will allow me to establish a reverse SSH tunnel?

I'd like to create a no-login account on my OS X (10.6.6) laptop at home so that I can establish a reverse SSH tunnel to it from my desktop at work. My intention is to create cron job (at work) that ...
3
votes
6answers
1k views

Can I do basic maths in Bash?

I was wondering, is it possible to do simple maths in bash? I'm thinking something like, =25-5 would print out 20 or something. Can this be done easily? Thank you
1
vote
4answers
182 views

What does this line of shell script do?

ls "${VMX_DIR}" | grep -q delta > /dev/null 2>&1; It lists the files in VMX_DIR and then pipes them into grep but what is it doing?
2
votes
2answers
261 views

Rename sets of files based on size

Background Rename one set of files based on a name that corresponds to another set, using a sort order based on file size to match the file names. The files from both sets have approximately the same ...
0
votes
1answer
53 views

Is there a tool similar to microsoft system centre configuration manager available on in Linux?

I am looking out for a tool similar to microsoft system centre configuration manager on linux platform which is available with GNU license and that can be used for doing multiple tasks like to ...
2
votes
1answer
1k views

Move running process to background

How do you move a running process to the background? For example, type the command sleep 60 on the command line and try moving that process to the background.
0
votes
3answers
2k views

Use sed to parse specific values out of a space-separated string

I have a file with lines like: 0 6 973 1346 2318 456 431 93 58 1 1 0 0 0 0 I want to extract the 1st, 4th and 5th number and save them in variables in bash for further use. In the example above the ...
4
votes
1answer
876 views

Bash: Replace all occurrences of a word in the last command

Almost by mistake, I figured out you could do something like: $ cp foo.data bar1.data $ ^bar1^bar2 And that runs the same command with bar2.data instead of bar1.data. Now, how about if I have ...
0
votes
2answers
393 views

bash: source from URL

In addition to my own computer, I sometimes use an Ubuntu cluster at my school. Rather than manually keep my .bashrc's in sync, I would like to make the school cluster's .bashrc source my personal ...
0
votes
2answers
497 views

BASH history manipulation: search replace

There is a really handy parameter/variable expansion feature in BASH that I don't see for history. I've checked man pages for history and for BASH itself. Not there ...maybe I missed it. Example: I ...
5
votes
3answers
324 views

Portable method of opening a new terminal window?

So, I'm working on a custom makefile script (for TinyOS, if anyone cares) that builds a file and then runs it in a simulator. The problem is that the simulator takes it's input from standard in, and ...
0
votes
1answer
1k views

start-stop-daemon works at command line but doesn't work in /etc/init.d script

I'm trying to get a starter script (for a ruby gem called ar_sendmail) working in /etc/init.d/ar_sendmail: #! /bin/sh echo "in /etc/init.d/ar_sendmail" DIR=/home/max/work/e_learning_resource/trunk ...
1
vote
2answers
761 views

emacs, colors in term-mode

I use Emacs and I run bash with M-x term command. There is a problem: colors in the *terminal* buffer aren't the same as in Gnome Terminal, and they are worse (do you need a screen shot?). How can I ...
0
votes
4answers
572 views

using awk to make exact matches

i'm just wondering how can we use awk to do exact matches. for eg $ cal 09 09 2009 September 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ...
0
votes
4answers
184 views

Creating a command that compress a file and save it on a usb, but cannot detect the usb in linux

First of all I can't detect the USB on linux using the command line. I check the directory dev and still cannot find the usb. used the df command to check the usb. I plug and typed df and then unplug ...
2
votes
1answer
478 views

Don't know why this small shell script wont work

I'm trying to make a small script to start up gunicorn for a python website I'm making. I have modified the script found at https://github.com/benoitc/gunicorn/blob/master/examples/gunicorn_rc ...
2
votes
1answer
218 views

Ignore types of files when you tab from the command line

One of the nice features of vim is that you can ask it to ignore certain types of files when you hit tab by using the following command in vimrc: set wildignore+=*.hi,*.pyc,*.o Is there a similar ...
2
votes
4answers
2k views

Using SQLite3 with Cygwin

I'm trying to use sqlite3.exe command shell with a mintty terminal in cygwin. I tried the program from a windows command prompt and it works. When I try to use it from the cygwin mintty terminal it ...
0
votes
1answer
236 views

Can I create a device in linux that is actually a memory-mapped file?

I want to speed up access to my .bash_history file. I have my PROMPT_COMMAND set to do history -a; history -r, so there is a significant delay in getting a new prompt. I want to see if I can speed ...
2
votes
1answer
944 views

Incrementing a variable by a real number (not integer) [closed]

I wanted to increment a variable, k inside a loop. Each increment is by 0.025. I tried using: let "k += 0.025" and let "$k += 0.025" and k += 0.025 and many other variations. Does anyone know ...
0
votes
1answer
314 views

Problem restoring from tar backup: why are there /dev/disk/by-id/ symlinks and how can I avoid them?

I'm trying to make a bare-bone backup system with the most basic tools available on openSUSE 11.3 (in this case: bash, fdisk, tar & grub legacy) Here's the workflow for my scripts: backup.sh: ...
0
votes
1answer
59 views

How to show regexp

I want to show what stands behind a regexp, for example, I want to print all chars covered by [A-z] in the bash.
3
votes
4answers
3k views

How can I batch rename files in bash?

I've got some files like this: database1-backup-01-01-2011.sql database2-backup-01-01-2011.sql ...etc. I want to rename them to add AM, like this: database1-backup-01-01-2011-AM.sql ...
1
vote
1answer
574 views

Single path exclusion from find (pruning)

Is there anyway to tell /usr/bin/find to blacklist a certain directory by absolute location. I'm using find (GNU findutils) 4.4.2. find . -type f -not -path '*/media/*' I would expect this never ...
3
votes
2answers
3k views

“ls” or regex is case insensitive?

In bash, I tried ls [a-z]* and expected to list all the files with filename starts with small case alphabet. But why the files with name starts with big case alphabet are also shown? >ls ...
2
votes
2answers
226 views

bash: How to abort building the list for tab complition without losing the command?

some_very_long_command_line --arg1 --arg2=555 --arg4 ... ... ... && <now Tab pressed> (Now it works. I want to cancel before the following message) Display all 6936 possibilities? (y or ...
0
votes
3answers
308 views

pop up a message if filesize smaller then 30 KByte

I have a zenity message box in a script zenity --info --text='done' > /dev/null 2>&1 I need to pop up a message, e.g.: "file is smaller then 30 KBytes!" when a file is smaller then 30 ...
2
votes
3answers
3k views

Can't edit /etc/profile on my mac

In terminal, I do this: sudo vi /etc/profile But I get a read-only version. I've never not been able to edit anything as a super user- What's going on?
1
vote
2answers
324 views

cut text from each line in a txt file

i have a text file where each line looks like this: <img border=0 width=555 height=555 src=http://websitelinkimagelinkhere> each line is like that for like 1500 lines, i want to sort of ...
4
votes
1answer
1k views

Bash - colored tab completion?

Is there a way to get colored output when using tab completion in a terminal? My colors are fine everywhere else so I know that I've enabled a color terminal successfully. Using bash in Ubuntu ...
3
votes
3answers
1k views

Add folder to PATH

How to add something to PATH ? I have added like PATH=$PATH:/home/example export PATH and it works until I restart , after that when I type env in PATH there is no /home/example.
3
votes
1answer
961 views

copy (split?) stdout instead of redirecting it

In Bash, I'd like to redirect stdout to a file (>> mylog.txt) but also see the stdout output on the screen.. How can I do it with bash?

1 44 45 46 47 48 63