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

learn more… | top users | synonyms

0
votes
3answers
523 views

How do I remotely execute scripts on multiple servers, mix output

Hi I'm looking for a piece of software or some sort of technique that would enable me to do following in one terminal window: Take as input a list of ssh-enabled machines with login, password and ...
0
votes
1answer
85 views

alias: extract options from command

Apologies for the bad title. I couldn't come up with a better one. I want to alias a command to another command, and extract options from the text of the command itself. I realize this is unclear, ...
0
votes
1answer
3k views

Sending commands to an existing screen session?

I have a Java app running in a screen session (A game server), and I'd like to be able to write a script to send commands to it periodically (with cron probably), but I'm not sure how to send commands ...
0
votes
1answer
156 views

Pause all but x CPU-intensive tasks

I've got about 50 folders of data to process, and I've got a ruby script that processes a folder's files (which folder it processes is based on a .yml configuration file). And a computer with four ...
12
votes
4answers
7k views

Ubuntu grep, find etc: “Permission denied” and “No such file or directory” output

When I grep or find something I always get annoyed by the "Permission denied" and "No such file or directory" notice, smth like that: johndoe@johndoe-desktop:/$ grep -rnP 'YII_CORE_PATH' ./ | grep -v ...
10
votes
4answers
3k views

Understanding pipe in bash

I dont quite understand how pipes work in bash. I know that it takes an output from one command as the input in another command. What an output is i can get because it's what the command prints out ...
8
votes
5answers
3k views

What does the linux pipe symbol “|” do? [duplicate]

Here is a command that sorts files in a folder in reverse order ls | sort -r What does the | symbol in that command do? What I'm really looking for here is high level (easy to understand) ...
8
votes
5answers
2k views

delete or rename a file with \r as the file name

I have a pesky little file whose name appears to be single character, and that character is a \r How can I delete this? This is what I get with ls -bl: -rw-rwxr--+ 1 root ...
8
votes
2answers
831 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
8
votes
3answers
4k views

Spawn New Cygwin Window from Within Cygwin

I can't figure out how to launch a new Cygwin session from within Cygwin, similar to launching a new terminal from within bash with: gnome-terminal It's probably easy but I am missing something. ...
7
votes
3answers
1k views

futurama bash scheme

Is there a color scheme for the BASH shell that matches the blackboard colors on futurama? (If it matters, I'm on OSX.)
6
votes
7answers
7k views

Linux: rename file but keep extension?

In Windows/DOS, I can say rename myfile.* yourfile.* to change the name but keep the extension. How is that accomplished on Linux? The man page only suggests how to change the extension, but that's ...
5
votes
4answers
243 views

Terminal: prefix previous command?

Frequently in Terminal (though I fully expect any answer will work in bash and most others), I type some command, and then get some sort of permission error due to missing sudo. Okay, so press 'up', ...
5
votes
2answers
182 views

Differences in bash scripts between $@ and $*

Which are the differences between $@ and $* ? For example I see no differences here: #! /bin/bash echo with star: $* echo with at sign: $@
5
votes
3answers
392 views

How do I detect when I a terminal gets focus in Linux?

I want to be able to time how long I spend in front of a terminal. I'm thinking the best way will be to have some sort of timer that starts and stops when the terminal gains/loses focus. And it will ...
4
votes
3answers
2k views

Sublime Text Editor command not found

I have installed Sublime on my Mac Lion Laptop, and followed the guide here http://www.sublimetext.com/docs/2/osx_command_line.html but as always it did not work. I dont have a ~/bin directory on my ...
4
votes
1answer
575 views

How to make bash alias invocation conditional on PWD?

I currently have this alias: alias cmakerel='cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev ../../ && make -j4' Essentially, it will call cmake to do an out-of-source build from PWD. It works ...
4
votes
3answers
4k views

What is the difference between Linux (Ubuntu) and Mac shell commands?

I use Ubuntu at work and a Mac at home. I was trying out some shell commands on my bash terminal on the Mac today but they didn't work. I was told both machines should operate UNIX commands so the ...
4
votes
1answer
638 views

how to move around files using “ls -al” result in Linux?

How can I write a script to copy files from one directory to another directory according to last modified date? ls -al -rw-r--r-- 1 user user 100 2011-05-26 12:33 ...
4
votes
2answers
409 views

on quit, 'less' does NOT clear its contents when run in a 'screen' session [duplicate]

Possible Duplicate: Using screen, commands like less and man don't clear the screen afterwards When I quit 'less' in a normal bash, it clears the previous contents displayed by 'less' ...
4
votes
3answers
356 views

/usr/bin/reset disables backspace

Following this question, running /usr/bin/reset destroys my backspace functionality. What can I do? After pressing backspace I get ^?
3
votes
4answers
183 views

What is ./ in BASH

I was playing around in a shell and typed ./. I go the following output: bash: ./: Is a directory It looks like "./" checks if a directory with the given name exist. I was trying to find ...
3
votes
2answers
4k views

BASH - merge directories when using mv

I just started using BASH, so I can move all contents of a directory to another. But the issue is, I was expecting it to merge the directories. I am using cron job to run this script. #!/bin/bash ...
3
votes
1answer
883 views

Ping server/domain and capture its IP on Linux

With Windows, you could ping a given domain name and capture the IP as a variable, even if no reply was received. I believe the command looked something like this: ping domain.com for /f "tokens=1,2 ...
3
votes
1answer
572 views

Parse multiple HTML to text and rename as parent Directory

In a directory there are many folders .html inside, I would like all HTML parsed as new .txt with the name of the parent directory. Example1/ Index.html>Example1.txt Example2/ ...
3
votes
2answers
162 views

Why I can access the dir // in Linux?

I found this dir in my ubuntu server momo@myubuntuserver:/$ cd / momo@myubuntuserver:/$ pwd / momo@myubuntuserver:/$ cd // momo@myubuntuserver://$ pwd // momo@myubuntuserver://$ cd /// ...
3
votes
2answers
679 views

Program to check/look up UTF-8/Unicode characters in string on command line?

I've just realized I have a file on my system; it lists normally: $ ls -la TΕSТER.txt -rw-r--r-- 1 user user 8 2013-04-11 18:07 TΕSТER.txt $ cat TΕSТER.txt testing ... yet, it crashes a piece of ...
3
votes
1answer
2k views

Bash script to wait for Virtualbox VM shutdown?

Virtualbox has the ability to issue a command to a running vm: vboxmanage controlvm NameOfRunningVM acpipowerbutton However this command returns immediately which results in non-graceful shutdown ...
3
votes
3answers
353 views

Why doesn't this for loop work?

This is on Ubuntu 12.04 I'm trying to figure out how to get ffmpeg to do a batch conversion of FLACs to MP3, recursively. If I cd into a directory and use for f in *.flac; do ffmpeg -i "$f" -c:a ...
3
votes
2answers
1k views

How to delete readonly variable in bash?

$ mySite="superuser" $ readonly mySite $ unset mySite bash: unset: mySite: cannot unset: readonly variable How can we delete mySite, as it is a readonly variable?
3
votes
1answer
2k views

Two parts: linux startup script to connect to bluetooth and cron to keep it connected

I have a mini bluetooth keyboard and a Raspberry Pi running a Debian-based distro. I know the MAC address of the keyboard but for this question, let's just use AA:BB:CC:DD:EE:FF. Right now I have to ...
3
votes
4answers
5k views

Setting ID3 title tag to be equal to MP3 file name

Has anyone got a bash script that will go through a media library and set the id3 title tag of each MP3 file to be equal to the file's name? I'm open to other automated methods too. It can be a GUI ...
3
votes
2answers
2k views

execute command after process terminates in different shell

I am running a command that's processing some data in one shell window (let's say it has pid 200). Unfortunately I forgot to add the & to run it in the background. I need to run some analysis ...
3
votes
2answers
296 views

is it plausible that Ubuntu's wildcard * with tar is somehow failing to restore some files?

In this command line sequence I use a *.sh wildcard to restore some files. I got three hits. Knowing that there must be more, I typed in the whole name. For example: goFindRanges.sh. I was able to ...
3
votes
2answers
2k views

Multiple parameters to bash script

I need to check for user provided options in my bash script, but the options won't always be provided while calling the script. For example the possible options can be -dontbuild -donttest -dontupdate ...
3
votes
1answer
370 views

How to shorten the no of characters display for the current directory in the prompt

I am using bash, and in my .basrhrc: I have the following which defined how my prompt looks: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\w\[\033[00m\]:\[\033[01;34m\]\!:\#\[\033[00m\]\$ ' ...
3
votes
5answers
2k views

How to run a bash script outside of a terminal?

Hey All, wrote this script to confuse my girlfriend when she is using my computer. The only trouble is that if the terminal gets closed the script stops to execute. It currently executes in the ...
2
votes
1answer
50 views

Creating directory name from file name - strip out non alpha numeric characters and make lower case

I am able to create a directory based on the name of a file. I am running into a wall if the text has spaces or non alpha numeric characters. I would like to strip out those non alpha numeric ...
2
votes
2answers
189 views

Slicing video file into several segments

I am currently using ffmpeg to slice video files. I automated the process through a script called ffmpeg_split.sh. Although this very slow it is efficient in splitting videos into equivalent settings. ...
2
votes
1answer
118 views

sed: Removing \r\r before \n in a very large file

I have a corrupted disk image file (about 27 GB) in which before all \n characters \r\r was inserted. I want to remove these \r\r before all \n. I tried with awk: awk '{ sub("\r\r$", ""); print }' ...
2
votes
3answers
1k views

Bash script, string not replaced correctly with escaped $ and & characters

I have created a shell script which takes a string as input. If the string contains $ or &, then I need to replace those characters with \$ and \&. I could done that with sed command. After ...
2
votes
3answers
127 views

I used mv ./*/* to flatten a directory on a ntfs filesystem, without add . to the end of the command, now all of my files are gone

How can I recover these files? I used: mv ./*/* when it was supposed to be mv ./*/* . Now all of my files are gone.
2
votes
1answer
2k views

Where to store bash scripts that all users may execute on Debian?

I have many bash scripts on my server, that all users may use. but it seems the location /usr/local/sbin is not the best place. I don't want to use the home directory of the users, cause ...
2
votes
3answers
452 views

Mail me when someone runs sudo

I have added the below lines to /etc/sudoers.d/my_sudoers Defaults mail_always Defaults mailto="email@domain.com" I get an email every time sudo is run How can i modify this so I only ...
2
votes
1answer
558 views

SSH not reading rc files

Once upon a time, an ssh invocation to host1 like ssh u@host1 command would read .bashrc before executing command. host2 is administered by the same people, and reads .bashrc! I don't administer ...
2
votes
1answer
5k views

Howto switch / chage user id witin a bash script to execute commands in the same script?

Is there a way to switch user identity within a script (executed as root as part of an installation process) to execute some commands without calling an external script, then return to root to run ...
2
votes
1answer
335 views

bash 4.2 autocd command default over directory

Just switched from tcsh to bash 4.2 on OSX, and autocd was what allowed me to do it. But it seems that by default if you type the name of a directory that also happens to be the name of an executable ...
2
votes
2answers
2k views

how to keep line feed in result returned by bash command

let's say, I can rsh to machine XXX as user foo, then after executing: $result=$(rsh -l foo XXX "ls"); echo $result; I found that the line feed is removed in the result, and I can't see the result ...
2
votes
1answer
195 views

Why is sort -k5nr not a syntax error?

$ ls -l | sort -k 5 -n -r $ ls -l | sort -k5nr I find out these two command generate the same output. But I don't understand why I can combine 5 with n? Why not a syntax error? edit: $ ls -l | cut ...
2
votes
2answers
280 views

Alias that allows to edit ~/.bashrc and then “sources” it automatically - Why it doesn't work?

I use MacBook Air with OSX 10.7.2. I would like to create an alias that does the following: Opens TextMate with ~/.bashrc and allows me to edit it Once I close TextMate, "sources" ~/.bashrc (so if ...