Skip to content

Instantly share code, notes, and snippets.

@acomjean
Last active July 1, 2024 17:52
Show Gist options
  • Save acomjean/29552e4a0080a69adfa0c3c3697928a8 to your computer and use it in GitHub Desktop.
Save acomjean/29552e4a0080a69adfa0c3c3697928a8 to your computer and use it in GitHub Desktop.
Bash Scripting

#Usefull Linux hint

Skip the first line of a file

tail -n +2 file.log

re order columns in file (cut maintains order) tab delimited

awk -F'\t' -v OFS="\t" '{ print $2, $5 }' input.tsv > output.tsv

add columns to file awk

awk '{FS=OFS="\t"; print "abc", $0, "xyz"}' temp.tsv

reformat columns using sprinf and awk (pad 10)

awk '{$1=sprintf("%10d",$1)}7' FS='\t' OFS='\t' $input

gff to bed format

awk -F'\t' -v OFS="\t" '{ print $2, $5, $6, $1, '1', $7   }' input.gff > output.bed

Miller Commands

add fbgns from symbol using miller

# add fbgns to markers (columns nameed gene)
mlr --itsv --otsv  join --ul -j gene -l gene -f original_data/N1_Markers.txt then unsparsify genelist.tsv > file with fbgn.tsv 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment