Feed on
Posts
Comments

Archive for the 'Shell Scripting' Category

to let the variable ‘j’ equal the output of a shell command, such as find, try: j=$(find `echo $i | sed ‘s/AnGST\/.*/AnGST\//’` -name “*.seq”) basically, it looks like all you need to do is enclose the command with a dollar-sign and some parentheses.  now, your shell scripts won’t need to be populated by unending lines [...]

i’ve just discovered sed.  this thing is wonderful; it’s like an in-line perl on the command-line.  now, it looks like i can use the shell to do things that even a perl program would be overkill for. for instance, i’ve got these files: [ldavid@subtilis data]$ ls ECprot119.phy   ECprot1519.phy  ECprot19.phy    ECprot2519.phy ECprot1219.phy  ECprot1619.phy  ECprot2019.phy  ECprot3119.phy ECprot1319.phy  [...]

here’s a shell for executing a ‘for loop’ on the bash command-line: for i in `ls boot*`; do echo $i; done

a simple task you might want to do in a shell script is perform some operation on every file in a directory. here’s the shell of code to do that: #!/bin/sh # iterate through all sequence files in this directory for phy_file in `find $1 -name “*.phy”` do echo $phy_file; done here, i’m stepping through [...]

to get the length of a string in the bash shell: ${#str_var}

« Prev

More blogs about http://desk.stinkpot.org:8080/tricks.