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

learn more… | top users | synonyms

2
votes
1answer
52 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 }' ...
1
vote
0answers
87 views

execl: couldn't exec `/bin/sh'

I accidentally moved the whole bin, boot, dev and etc directory. After moving everything back I get the following error email from various cron jobs: execl: couldn't exec `/bin/sh' execl: No such ...
3
votes
3answers
1k views

How to find the default file manager?

as a Linux user, I see that some applications can request a path to be opened and this causes a file manager to be launched. I'd like to do this programmatically, but how can I know which is the ...
11
votes
2answers
4k views

Putty SSH: CTRL+Cursor keys don't work skip to previous/next word

When I am connected to my local Ubuntu dev server with putty (from my Windows 7 box) via SSH, the following key combinations don't work to move the cursor forward and backward on word boundaries: ...
2
votes
2answers
61 views

sed: How can I replace \r\r\n?

In this question on stackoverflow it is explained how one can replace a newline character using sed. My problem is that I want to replace the character sequence \r\r\n with sed. Can somebody help me ...
30
votes
4answers
26k views

Bash: Iterating over lines in a variable

How does one properly iterate over lines in bash either in a variable, or from the output of a command? Simply setting the IFS variable to a new line works for the output of a command but not when ...
0
votes
2answers
29 views

Quote with brackets

How can I quote with brackets in order to prevent Bash interpretation? I know it's possible for command substitution: echo \"`echo "I will be in quote"`\" echo \"$(echo "I will be in quote")\" # same ...
0
votes
1answer
17 views

Concatenate header of one file with tail of another

I have a large gzipped mysqldump file which contains some table definitions and then many insert statements. I'd like to edit the table definitions but leave the insert statements alone. The file is ...
1
vote
0answers
22 views

scp doesn't work when my .bashrc is echoing to console

Ok, so I have used linux for a long time but this is the weirdest thing I have encountered in a long time. Maybe I just don't do a lot of scp so probably missing something simple here. So in my ...
0
votes
2answers
82 views

Creating a simple custom apt-get/config script

As I play more and more with Ubuntu, I'm starting to see how I can automate the majority of the repetitive commands that I perform whenever I reinstall the operating system. Thus far, it's just one ...
0
votes
1answer
20 views

Live CD: Script doens't work correctly after login

I have a PXE/NFS Server (192.168.1.10), a client PC and a diskless PC. I installed base ubuntu 12.04 to client PC. I wrote this script (update.sh) to work after login to client PC. ...
3
votes
1answer
50 views

#!/bin/bash -e :: what is `-e`? other arguments?

I am a shell script coder that always opt to use shell as top level as part of my belt in creating website apps on the fly and have relied on my bash scripts if I want a project to be implemented ...
0
votes
0answers
15 views

Save rows effected from mysql delete statement in bash

I am trying to create a bash script that will connect to my database and purge older records, I would like to keep a record of the number of rows are deleted in a file (lets call it rowseffected.log). ...
0
votes
2answers
23 views

How to delete Exported folder (SSH)

I have used command: export TMPDIR=$HOME/tmp Now it created /tmp folder in my root directory (root/tmp) How can i delete it?
12
votes
3answers
731 views

What does . .bashrc actually do?

When I enter a eg. a new alias into my .bashrc file I can't use it in that terminal window immediately and until recently I thought I had to restart the terminal to reload the .bashrc file. Then I ...
1
vote
1answer
37 views

Bash command substitution and variable issue

I am writing some simple backup utility in bash and any output must be in JSON. I am checking for host reachability and if any error occurs, I want to print it out. However, I have an issue with ...
0
votes
1answer
22 views

How do I separate files in groups for aggregate processing?

Suppose I have lots of files in a directory, and I need to concatenate clusters up to 100 files into a new file. How could I do this in bash? For the purpose of this question, let's assume that I ...
3
votes
3answers
312 views

What is the `[` command? [duplicate]

I have seen both in Cygwin and in Linux the [ command under /bin. Whenever I run it I get an error saying: missing ]. I never understood what this command does, I just one day found it wanted to ...
9
votes
8answers
26k views

bash: how to pass command line arguments containing special characters

I've written myself a linux program program that needs a regular expression as input. I want to call the program in the bash shell and pass that regular expression as a command line argument to the ...
8
votes
7answers
536 views

Per-directory bash/zsh history log files

I find I do a lot of work on a project in a set directory. Sometimes — a few months down the track — I need to redo something on that project but I can't remember what I did. I use ...
4
votes
3answers
587 views

How do I turn of “auto-echo” in bash when I 'cd'?

I don't know when this started happening but now, every time I cd to a directory it echoes the path right before it changes directories. This happens when I log into a server but doesn't happen on my ...
1
vote
1answer
151 views

Is it possible to have App-distinct Color Scheme in ConEmu?

I am presently using Bash (with Cygwin), as well as Powershell, both using ConEmu. I'm using bash.exe and powershell.exe via tasks. I'd like to use different colour schemes for the different ...
2
votes
1answer
44 views

Is there a way around broken pipe?

I have a directory with a large number of files. ./I_am_a_dir_with_many_subdirs/ Within a script I'd like to find all subdirs in it, to sort them and to output to a bash array. So, I do: ...
41
votes
6answers
11k views

What is the difference between executing a bash script and sourcing a bash script?

What is the difference between executing a bash script like A and sourcing a bash script like B? A >./myscript B >source myscript
0
votes
2answers
36 views

Bash substring last occurance of a character

I am trying to write a script that removes everything after the last occurrence of a character. For example if the string is DATETIME 2014.03.14 12:23:24, I would like to get just DATETIME 2014.03.. ...
0
votes
2answers
27 views

the same tr translate failed on some of machine

I use the following code and failed. $ echo $TERM xtermc $ v=/bin:/usr/bin:/usr/local/bin ; echo $v | tr ':' '\n' /binn/usr/binn/usr/local/bin It seems skip my '/'. I don't know how to solve this. ...
0
votes
1answer
13 views

Bash return stderr of the first failed process

I need to run some commands and if any of those fails I would like to output JSON with it's stderr. I have the following line: OUT="$( (ssh internal "custom_script1" | custom_app1 2>&- | ...
0
votes
0answers
16 views

Capture user input to “kinit” - Works on OS X, but not Linux via “script”

I have a script that was written on OS X and utilizes the "script" command. With the -k flag it will log keys sent to the program, but that option is not available in the linux version of "script". My ...
3
votes
2answers
4k views

Cygwin Dos2Unix Command not found

I am having some problems using cygwin. I am trying to use the dos2unix utility and cygwin is throwing -bash: dos2unix: command not found When I go back into the installer and look through the ...
0
votes
0answers
31 views

How to check via bash if your connection is wireless N/G/… on Linux?

iwlist scan shows me the available wireless connections. I can see Frequency:2.412 GHz for the channel I'm connected to. This article shows that a frequency of 2.412 GHz means that you are using ...
1
vote
1answer
31 views

What is the AIX's `ps -T PID` equivalent for Linux?

I really like the way ps -T PID works on AIX. It shows you a nice tree of processes in the right side, and their PID, PPID and other info in the left side. In AIX docs, the -T flag reads Displays ...
3
votes
2answers
137 views

restrict rsync (or bash script) to a directory

After a bad accident with rsync deleting wrong files due to wrong destination parameter, I want to restrict rsync (or the bash script running it) to be able to delete/modify files only under a certain ...
1
vote
0answers
40 views

Postgresql query within a bash script

We are having an issue with a postgresql bash query. The output of the query from the bash script add's additional quotes around the date. Please can you help me fix it?! Script: #!/bin/sh ...
3
votes
1answer
53 views

Using grep to filter output of a process

I'm using command | grep -v "JavaScript strict warning" to filter the output of a command (hiding warnings). The grep command works fine when I test it like this: $ printf "JavaScript strict warning: ...
0
votes
0answers
13 views

(MAC) Change location of shell script's shell

When I make an executable shell script ("http://chimpy.wordpress.com/2010/08/29/mac-os-x-shortcut-link-to-python-script/", but without the python part), It's pointer location (The location commands ...
0
votes
1answer
50 views

VLC bash transcoding script destination directory

Well, I have such transcoding script: #!/bin/bash acodec="vorb" arate="256" ext="ogg" vlc="/usr/bin/vlc" fmt="mp3" for a in *$fmt; do $vlc -I dummy -vvv "$a" --sout ...
5
votes
3answers
10k views

How to reset Bash on Mac OSX, .bash_profile corrupted and bash no longer works

I am on a MacBook Pro, running the latest version of Mountain Lion. I really need some help, I have managed some how to damage my .bash_profile (I think) so that every time I open up the terminal I ...
0
votes
1answer
27 views

How can I encode an url for wget?

I am looking for a way to convert a string to a clean url. For example : wget http://myurl.com/toto/foo bar.jpg This is going to download http://myurl.com/toto/foo and http://bar.jpg. I want to ...
0
votes
1answer
38 views

VLC bash transcoding script output to file

I'm running such script to transcode my audio files: #!/bin/bash acodec="vorb" arate="256" ext="ogg" vlc="/usr/bin/vlc" fmt="mp3" for a in *$fmt; do $vlc -I dummy -vvv "$a" --sout ...
0
votes
1answer
41 views

Solution for automatic VPN-Connection on Ubuntu 13.10

I am searching since ages for a solution to connect to VPN-Servers automatically in my Ubuntu 13.10. It should connect on startup and reconnect on connection-drop. I tried several things: ...
1
vote
3answers
82 views

Tool to record an interactive bash session to shell script

Is there a tool to record an interactive shell session to a shell script? For example if we entered in a terminal: interactive2sh reconfig_foo vim /etc/foo.cfg ibar^ESC:q /etc/init.d/foo restart ...
1
vote
1answer
46 views

How can I run a Cygwin command (not a Windows native command) as privileged?

If I open a (elevated via UAC) Bash Shell in CygWin: Luis@Kenobi /cygdrive/c/Windows/system32 $ crontab.exe -l -u Luisito must be privileged to use -u Tested on WinXP-SP3 and Win7-SP1. Same results ...
0
votes
0answers
25 views

Aptana github and project

Ok so this problem is making my brain to nuts. I created a new php project in aptana a couple of days ago, and I was using git bash to commit/push things onto github, and I guess aptana automatically ...
0
votes
0answers
26 views

open a new screen in linux, no access to perl local library

I added my perl local library to my shell startup script (.bashrc) and when I start a terminal in linux: $ echo $PERL5LIB /home/perl5/lib/perl5:/usr/share/vcftools/perl BUT when I open a new ...
12
votes
8answers
907 views

Bash Script to repeat every word in a line?

I have a string like: dog cat bird whale And I want to get dog dog cat cat bird bird whale whale All the words are in the same line. Any idea?
0
votes
1answer
31 views

Exact location of usr/local

I can't seem to find the exact location of usr/local on OS X. I want to install homebrew because I installed it in a bad way and want do do a reinstall. Homebrew recommends installing in usr/local ...
0
votes
1answer
42 views

input from shell in bash script

i have a bash script i would like modify to support input from shell atm i have to type the link after i have run the script wiak@test:~$ scripts/lget.sh gimme cookie! ...
1
vote
1answer
20 views

Can't get a bash to work with python on a SGE

I'm currently working on a SGE and I'm extremely unfamiliar with the linux environment. I have to execute python scripts but the setup is kinda confusing for me and I can't get it to work. The ...
2
votes
1answer
64 views

Paste a URL in terminal using bash script on Ubuntu

I'm on Ubuntu 12.04. I need to write a Bash script which would automatically paste a URL to the terminal without having to press CtrlShiftV on the keyboard. The script contains the command: wget -O ...
0
votes
1answer
65 views

installing software without package manager

I have an embedded system running linux. I need to install some software, in particular uucp package containing cu command. This is really all i need. At the moment all I have is a root access to the ...