bash

Uppercasing First Letter of Words Using SED

How do you replace the first letter of a word into Capital letter, e.g. Trouble me Gold rush brides into Trouble Me Gold Rush Brides ...

How to force bash autocomplete to one command ?

Hello guys, I just upgrade to Ubuntu Karmic 9.10 and there is now emphaty. The problem is that em-TAB- doesn't autocomplete to emacs anymore ... I there a way to the my Bourne-Shell to complete em-TAB- always to emacs ? Thank you ...

Converting FASTQ to FASTA with SED/AWK

I have a data in that always comes in block of four in the following format (called FASTQ): @SRR018006.2016 GA2:6:1:20:650 length=36 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGN +SRR018006.2016 GA2:6:1:20:650 length=36 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!+! @SRR018006.19405469 GA2:6:100:1793:611 length=36 ACCCGCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC +SRR...

Linux BASH memory leak when redirecting stdio

I've got a memory leak somewhere, but it doesn't appear to be related to my program. I'm making this bold statement based on the fact that once my program terminates, either by normal means, seg-faulting, or aborting, the memory isn't recovered. If my program were the culprit, I would assume the MMU would recover everything, but this d...

How can I get my git (msysgit on windows) post-commit script to invoke my python script as python rather than bash?

I wrote a post commit script in python, "c:\myfolder\myscript.py". I want to invoke it from the post-commit script. This doesn't find it: #!/bin/sh c:\myfolder\myscript.py bash thinks the command c:myfoldermyscript.py - the slashes get dropped. So, I tried forward slashes: #!/bin/sh c:/myfolder/myscript.py But then it seem...

Shell script (mac): How to download files from a directory using wget and regular expression?

I'm trying to download images (.jpg) from web folder using wget. I want to download only images, which have a certain sentences in file name. This works fine wget -r -nd -A .jpg http://www.examplewebsite.com/folder/ but I like to include a sentence eg. "john". I tried wget -r -nd -A .jpg '*john*' http://www.examplewebsite.com/folde...

bash script to edit xml file

I want to edit the config file of a program that is an XML <software> <settings> .... </setting name="local directory" type="string">/home/username/</setting> .... </settings> </software> What is the easiest way to do this from a bash script. Thanks ...

Preserving whitespaces in a string as a command line argument

I'm facing a small problem here, I want to pass a string containing whitespaces , to another program such that the whole string is treated as a command line argument. In short I want to execute a command of the following structure through a bash shell script: command_name -a arg1 -b arg2 -c "arg with whitespaces here" But no matter how...

echo in a bash script changing '--md5' to '?-md5'

Hi, I'm writing a VMWare ESX automated build script and I'm falling at the last hurdle, probably as I'm really not strong at scripting. I need to secure Grub so in my script I have a like saying; echo "password --md5 password-converted-to-md5" >> /boot/grub/grub.conf This unfortunately places the following into this file; password ...

Common Pitfalls in BASH programming

I am not able to find this particular discussion in SO. What are all the common mistakes and pitfalls in the BASH programming / shell scripting? PS: Please close if this has been discussed already. ...

MacPorts/Unix/bash question

I'm new to all things shell/binary, and was installing git (I understand scm is a good thing from being on SO). My internet hiccuped partway through, however, and the installation stalled. It interrupted a tar.gz download, and I don't know quite how to resume where it left off. Here's the output: computer:~ Alex$ sudo port install git...

Bash Can not get IF to work like I want to

I need to understand bash if expressions. Sure, I've used Google. I know that it goes something like this: if [ expr operator expr ] then doSomeThing fi However, I understand that Bash doesn't have a boolean data type. I want to check if the file passed as an argument ($1) exists. The way I would do this straight of my mind: if [ -...

Bash comparing stored "boolean" value with what?

Hi, I'm trying to make a program that takes in one argument. A file. And then checks what has happened to the file 60 seconds later. To do this, I need to store the result from "-e $1" in a variable and then check it 60 seconds later. I can not seem to be able to make the if expression listen to me, and I know it's wrong. For testing pur...

Appending Text To the Existing First Line with Sed

I have a data that looks like this (FASTA format). Note that in comes with block of 2 ">" header and the sequence. >SRR018006 NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGN >SRR018006 ACCCGCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC What I want to do is to append a text (e.g. "foo" in the > header) yielding: >SRR018006-foo NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

Bash shell scripting - csv parsing

I am trying to parse a CSV containing potentially 100k+ lines. Here is the criteria I have: The index of the identifier The identifier value I would like to retrieve all lines in the CSV that have the given value in the given index (delimited by commas). Any ideas, taking in special consideration for performance? ...

Switch from file contents to STDIN in piped command? (Linux Shell)

I have a program (that I did not write) which is not designed to read in commands from a file. Entering commands on STDIN is pretty tedious, so I'd like to be able to automate it by writing the commands in a file for re-use. Trouble is, if the program hits EOF, it loops infinitely trying to read in the next command dropping an endless to...

Bash: find and copy

Hi, Anybody has an alternate way of finding and copying files in bash than: find . -ctime -15 | awk '{print "cp " $1 " ../otherfolder/"}' | sh I like this way because it's flexible, as I'm building my command (can by any command) and executing it after. Are there other ways of streamlining commands to a list of files? Thanks ...

BASH scripts : whiptail file select

I've found a great little program that will allow me to add user friendly GUI's to my Bash Scripts; whiptail However the whiptail man page isn't all that helpful and doesn't provide any examples. After doing some google searches I understand how to create a simple yes/no menu using whiptail: #! /bin/bash # http://archives.seul.org/s...

Handle special characters in bash for...in loop

Suppose I've got a list of files file1 "file 1" file2 a for...in loop breaks it up between whitespace, not newlines: for x in $( ls ); do echo $x done results: file 1 file1 file2 I want to execute a command on each file. "file" and "1" above are not actual files. How can I do that if the filenames contains things like spaces ...

How to parse links in bash output

Let assume that we have this output in bash console: $ findgrep RAILS_ENV ./script/munin_stats:7:RAILS_ENV = ENV['RAILS_ENV'] || "development" ./script/munin_stats:12: dbconfig = dbhash[RAILS_ENV] ./lib/tasks/juggernaut.rake:4: @rails_env = ENV["RAILS_ENV"] || "development" ...