Skip to content

Instantly share code, notes, and snippets.

View lancelothk's full-sized avatar

Ke Hu lancelothk

  • Case Western Reserve University
  • United States
View GitHub Profile
#!/bin/bash
if [ ! -d "$3" ]; then
mkdir $3
fi
for file in $2/*
do
outputFile=${file/$2/$3}
#echo "perl $1/fastq2fasta_out.pl $file ${outputFile/fastq/fasta}"
perl $1/fastq2fasta_out.pl $file ${outputFile}.fasta
done
@lancelothk
lancelothk / gist:1b46373a33026acce96f
Last active August 29, 2015 14:05
Example of shell script – change file extension:
copy from http://www.ibm.com/developerworks/aix/library/au-unixtext/
Example of shell script – change file extension:
$ cat setup_files.ksh
mkdir /tmp/mv_demo
[ ! -d /tmp/mv_demo ] && exit
cd /tmp/mv_demo
mkdir tmp JPG 'pictures 1'
touch a.JPG b.jpg c.Jpg d.jPg M.jpG P.jpg JPG_file.JPG JPG.file2.jPg file1.JPG.Jpg 'tmp/
pic 2.Jpg' 10.JPG.bak 'pictures 1/photo.JPG' JPG/readme.txt JPG/sos.JPG
@lancelothk
lancelothk / gist:a2a9a11f8df503d2a893
Last active August 29, 2015 14:05
Example of shell script – string extraction:
copy from http://www.ibm.com/developerworks/aix/library/au-unixtext/
Example of shell script – string extraction:
$ cat string_example1.sh
#!/bin/sh
FILEPATH=/home/w/wyoes/samples/ksh_samples-v1.0.ksh
echo '${FILEPATH} =' ${FILEPATH} " # the full filepath"
echo '${#FILEPATH} =' ${#FILEPATH} " # length of the string"
echo '${FILEPATH%.*} =' ${FILEPATH%.*} " # truncate right of the last dot"
echo '${FILEPATH%%.*} =' ${FILEPATH%%.*} " # truncate right of the first dot"
echo '${FILEPATH%%/w*} =' ${FILEPATH%%/w*} " # truncate right of the first /w"
@lancelothk
lancelothk / gist:f8f4b635666cdb4cc895
Last active February 26, 2019 00:09
sed1line.txt
copy from http://sed.sourceforge.net/sed1line.txt
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages: