Skip to content

Instantly share code, notes, and snippets.

@DSuveges
Last active December 13, 2017 14:25
Show Gist options
  • Save DSuveges/e72e26177fea53a6eca88281dc66cf6c to your computer and use it in GitHub Desktop.
Save DSuveges/e72e26177fea53a6eca88281dc66cf6c to your computer and use it in GitHub Desktop.
Frequently used bash one liners and functions.
# Find failed lsf jobs based on the output logs, also why did it failed:
find . -type f -name "*.o" -exec grep -L "Successfully completed" {} \; | xargs grep TERM
# Extract failed jobs, restart:
find . -type f -name "*.o" -exec grep -L "Successfully completed" {} \; | while read f; do
command=$(echo $f | xargs -I {} grep -H -A1 "User input" {} | sed -r -e 's/ +/ /g' | grep -v "#" | cut -d- -f2-)
chunk=$(grep -i "Subject: Job" $f | perl -lane '$_ =~ /\d+\[(\d+)\]/; print $1')
echo "$command -c $chunk"
done | ~ag15/array 5g restart
# Transposing file stream:
function transpose(){
awk'
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment