awk command အကြောင်းကို ဒီမှာ လေ့လာရမှာဖြစ်ပါတယ်။
command တွေကို content မှာ လေ့လာနိုင်ပြီး ၊ command အကြောင်းကိုတော့ Video မှာ ရှင်းပါပေးထားပါတယ်။
awk အကြောင်း —-
awk command usage:
#awk option filename.txt
-F (file separator) fs
-f (file)
-v ( var=value) to declare a variable
Read awk scripts
#awk ‘{print $1}’ myfile
#e.g — #awk ‘{print $1}’ bnntech.txt
Using Variables
. $0 for the whole line
. $1 for the first field
. $2 for the second field
etc …
#awk -F: ‘{print $1}’ /etc/passwd
Multiple commands
#echo “hello bozin” | awk ‘{$1=“hi”; print $0}’
Reading the script from a file
အောက်က scrip က ဖိုင်ထဲမှာရှိနေခဲ့မယ်ဆိုရင်
#echo ‘{print $1 “ my home is “ $6}’ > bnntech.txt
#awk -F: -f bnntech.txt /etc/passwd
using awk with pipeline
ifconfig | awk ‘NR==2{print $2}’
SED command
$echo “welcome to yangon” | sed ‘s/yangon/mandalay/’
multi sed linux command
$sed -e ‘s/ygn/mdy/; s/welcome to/hello from/’ filename
တစ်လုံးထက်ပိုသောစကားလုံးပါလာတဲ့အခါ ကိုပြောင်းချင်တဲ့ စာလုံး
ဘယ်နှစ်လုံးမြောက်ဆိုတာကိုပြောင်းချင်ရင်
$sed ‘s/ygn/mdy/2’ filename (ygn ၂လုံးပါလာရင် ဒုတိယအလုံးကိုပြောင်းမှာ)
$sed ‘s/ygn/mdy/g’ filename (အကုန်ပြောင်းမှာ)global repacement
$sed -n ‘s/ygn/mdy/p’ filename (line ရဲ့ပထမ စာလုံးပဲ ပြောင်းမှာ)
$sed ‘2s/ygn/mdy/2’ filename (2s ဆိုတာ line no နဲ့ change တာ)
$sed -i ‘s/ygn/mdy/2’ filename
$sed -i ‘/mdy/d’ filename
Linux basic to Linux system administration class စုံးစမ်း အပ်နိုင်ရန် အတန်းချိန်တွေကို အောက်မှာ လေ့လာနိုင်ပါတယ်။

