Skip to content

Bash One liners

Export Inkscape SVG files to EPS for PLOS journals

-T converts text to outlines so that fonts do not have to be embedded.

for file in *.svg; do inkscape -T -o ${file/svg/eps} $file; done
zcat <FASTQ.GZ> | head -n 100 | sed -n 2~4p

Replace FASTQ read name by ascending numbers starting at 0

gzip -dc <INPUT.FASTQ.GZ> | \
    awk 'BEGIN {line=3;read=0} ++line==4 {$0="@"read;line=0;read++} 1' |  \
    gzip > <OUTPUT.FASTQ.GZ>

Transferring snapgene exported primer files to local desktop

rsync "serine://home/common/Desktop/rasi/Primers from to be cloned"* /home/rasi/desktop/

Looking for specific primers in snapgene exported primer files

This looks for primers starting as oAS8 followed by 6, 7, 8, or 9 in the snapgene-exported files.

for file in "Primers from "*; do grep "oAS8[6789]" "$file" > "${file/txt/tsv}"; done

Mounting snapgene from serine onto your local machine

sshfs "serine://home/common/git/snapgene_maps/DNA Files" /home/rasi/mounts/snapgene/

Logging into serine and opening snapgene

ssh serine
sh /opt/gslbiotech/snapgene/snapgene.sh
for file in */analyze_results.md; do sed -i -r 's/.+(analyze_results_files.+)/![](\1/p' $file; done

Find the largest files in your current directory and its sub directories.

You might want to check and delete these periodically.

  • First navigate to the directory you want to check.

  • The following command will print out the size and location of the 30 largest files in your current directory and its subdirectories.

    find . -type f -printf '%s\t%p\n' | sort -nr | head -30
    
  • Once you have identified these files, delete the useless ones using rm FILE_LOCATION.

Export only recently modified .svg files to .png

This works for files in the current working directory.

for file in `find *.svg -type f -mmin -60`; do newname=${file//svg/png}; inkscape --export-png=$newname --export-dpi=300 $file; echo $newname; done

Check if a file does not exist

for folder in processeddata/*; do if [ ! -f "$folder"/gencode.genome.bam ]; then echo $folder; fi; done