Last active
January 28, 2020 11:58
-
-
Save ilkayisik/39d1012c38ba4df70ad9da391610f942 to your computer and use it in GitHub Desktop.
Example script containing several important operations in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# How to skip the first line while using read, | |
# how to check a value and increment based on the value of another variable, | |
# pipe a value from bash to awk to parse the line and get the value as a variable to use in another bash command | |
PREVCINDEX=99999 | |
i=1 # skip the first line (part 1) | |
while read LINE | |
do | |
test $i -eq 1 && ((i=i+1)) && continue # skip the first line (part 2) | |
CINDEX=$(echo LINE|awk '{print $1}') | |
if [ ${VAR01} -ne ${IND} ]; then | |
ROI_NR=1 | |
else | |
ROI_NR=$((ROI_NR + 1)) | |
fi | |
#X=$(echo $LMAXLINE | awk '($1 !~ /Cluster/){print $3}')# if you want a not equal statement in AWK | |
X=$(echo $LINE|awk '{print $3}') # select the value form this line on the 3rd column for the variable | |
PREVCINDEX=$CINDEX | |
done < ${MYFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment