bash

Quickest language to make a little 'Connect to a SSL webpage' script

Hi! I just need some advice. I already know how to play with bash, ruby, python and perl and I'd like to know: with which of them would it be faster to make a little script that would connect to a website with SSL and login. I just need to do this script and make a cron job with it. So it must be executable from the console. Thanks. ...

How to get an array of .png files in a folder using Bash

Hi I am a newbe to bash programming and need some help. I am building a pipeline for image processing. I would like to be able to take the png images in a folder and pass them to clusterImage.pl once that is done I would like to then pass the outputted file to seperateObjects.pl the outputted file is of the same name but has kmeansOutput...

Bash command to sum a column of numbers

I want a bash command that i can pipe into that will sum a column of numbers: I just want a quick one liner that will do something essentially like this: cat FileWithColumnOfNumbers.txt | sum Anybody have one in their back pocket? ...

fork and exec in bash

How do I implement fork and exec in bash? Let us suppose script as echo "Script starts" function_to_fork(){ sleep 5 echo "Hello" } echo "Script ends" Basically I want that function to be called as new process like in C we use fork and exec calls.. From the script it is expected that the parent script will end and then after 5 seco...

Whitespace escape when substituting one bash variable into another variable

I'm having trouble preserving whitespace in a bash script: CURRENT_YEAR=$(date "+%Y") MESSAGE=$(eval echo "$(/usr/libexec/PlistBuddy -c "Print NSHumanReadableCopyright" Info.plist)") /usr/libexec/PlistBuddy -c "Set NSHumanReadableCopyright $MESSAGE" ${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH} The relevant section Info.plist: <NSHum...

How To Sort Tab Format File Based on Length of Column K

I have a space delimited tabular file that looks like this: >NODE 28 length 23 cov 11.043478 ACATCCCGTTACGGTGAGCCGAAAGACCTTATGTATTTTGTGG >NODE 32 length 21 cov 13.857142 ACAGATGTCATGAAGAGGGCATAGGCGTTATCCTTGACTGG >NODE 33 length 28 cov 14.035714 TAGGCGTTATCCTTGACTGGGTTCCTGCCCACTTCCCGAAGGACGCAC How can I use Unix sort to sort it by leng...

How to make AWK use the variable created in Bash Script

I have script that looks like this #!/bin/bash #exampel inputfile is "myfile.txt" inputfile=$1 basen=`basename $inputfile .txt` # create basename cat $inputfile | awk '{print $basen "\t" $3} # this doesn't print "myfile" but the whole content of it. What I want to do above is to print out in AWK the variable called 'basen' created...

Why can't I use Unix Nohup with Bash For-loop?

For example this line fails: $ nohup for i in mydir/*.fasta; do ./myscript.sh "$i"; done > output.txt& -bash: syntax error near unexpected token `do What's the right way to do it? ...

Run pdb without stdin/stdout using FIFO

I am developing FUSE filesystem with python. The problem is that after mounting a filesystem I have no access to stdin/stdout/stderr from my fuse script. I don't see anything, even tracebacks. I am trying to launch pdb like this: import pdb pdb.Pdb(None, open('pdb.in', 'r'), open('pdb.out', 'w')).set_trace() All works fine but very...

Bash: Concatenate all arguments and wrap them with double quotes

function foo() { A=$@... echo $A } foo bla "hello ppl" I would like the output to be: "bla" "hello ppl" What do I need to do instead of the ellipsis? ...

bash: store all command-line args after all parameters

Hi, how I can create this small script? For example: ~$ script.sh -b my small string... other things -a other string -c any other string ant etc I want only string, every have a mode. -b my small string... other things -a other string -c any other string ant etc Anyone know how implements it? Thanks ...

Removing Parts of String With Sed

I have lines of data that looks like this: sp_A0A342_ATPB_COFAR_6_+_contigs_full.fasta sp_A0A342_ATPB_COFAR_9_-_contigs_full.fasta sp_A0A373_RK16_COFAR_10_-_contigs_full.fasta sp_A0A373_RK16_COFAR_8_+_contigs_full.fasta sp_A0A4W3_SPEA_GEOSL_15_-_contigs_full.fasta How can I use sed to delete parts of string after 4th column (_ separat...

psql import file

In postgresql and bash(linux), are there ways to directly import a file from the filesystem like [execute.sh] pgsql .... -f insert.txt [insert.txt] insert into table(id,file) values(1,import('/path/to/file')) There seems to be no import function, bytea_import as well, lo_import would save int and i dont know how to get the file bac...

linux bash 'sort' in dictionary order - problem with zeros

Hi, I'm seeing something strange with 'sort' in RedHat Enterprise Linux 5 x86_64 and in Ubuntu 9.1. I'm using bash. First here's what I think is right to expect from sort using dictionary order: [stauffer@unix-m sortTrouble]$ cat st1 1230 123 100 11 10 1 123 1230 100 [stauffer@unix-m sortTrouble]$ sort st1 1 10 100 100 11 123 123 1...

Emacs ... as your default shell?

Is it possible instead of loading /bin/bash, for my terminal to load emacs or emacsclient when I open it up, with a session for eshell? And is it feasible to ssh->screen from an emacs session without running into problems? I want to do this purely to learn about emacs being as I like it so much. No hate text, etc please :) ...

Setting a BASH environment variable directly in AWK (in an AWK one-liner)

I have a file that has two columns of floating point values. I also have a C program that takes a floating point value as input and returns another floating point value as output. What I'd like to do is the following: for each row in the original, execute the C program with the value in the first column as input, and then print out the...

Problems with simple bash commands in the shell

Hello, I need to add java to my PATH on one of my Linux servers, to do this I edited the bashrc and added, PATH=/usr/local/jdk1.6.0/bin export PATH Since then I have not been able to use simple bash commands like ls nano locate cp is there any way I can fix this? The OS of the server is CentOS 5 with Plesk 9 (64-bit), can anyone help...

shell command in groovy

How to run this command in groovy : /home/srinath/junk/sync.sh > /home/srinath/junk/copy.log This is working when tried on terminal . but fails when used execute in groovy Could any one please help me on this . thanks in advance sri.. ...

How to get the CLI parameter from bash?

test.sh parameter in test.sh, how can I get the parameter ? ...

Find Longest Line in a .txt File and fill all Lines to that Length with 'blank Spaces'?

How can I find the longest line in a .txt file and then fill all other lines at their end to that length with blank spaces? My guess is this is easy to answer. I know very little about using the awk, paste command and such. Maybe someone can help me out. Thanks! A little more specific... so far I can do the following. This would get th...