跳到主要內容

Pass an outside variable into awk

awk -v var=value_of_wherever '$1 >= var' input_file

See the following example

#/bin/bash

let i=1
for ((i=1; i<=5; i++)); do # this is also called the C-like loop

echo 'i = ' $i
echo -n 'Now see awk result: '
awk -v test_value=$i '$1 == test_value' data_file
# use -v option in awk to assign the variable $i
# to test_value,
which is passed inside the awk
# command inside quotes.

done

留言

這個網誌中的熱門文章

安裝 Linux mint 17 的efi分割區

2016 / 7 / 17 更新: 測試了Linux Mint 17.3,沒問題,我採用單系統,就是沒有Windows whatsoever installed 底下註1的提醒,不會出現,所以要自己記得要:用EFI模式開機、 記得自己增加一個EFI partition、製作這個partition時,種類選擇EFI 即可,下面的3.說的步驟可以省略。 我的EFI partition大小為200 MB,為sda1。這是完全用猜的。 Figure credit: linuxmint.com 2015 / 9 / 10 更新: 根據  Dual Boot openSUSE 13.2 and Windows 8.1 UEFI » TweakHound 的步驟,可以解決安裝好不能開機的問題。雖然他講的是針對OpenSuse的操作,但是開機、EFI分割區等概念是相通的。在OpenSuse 13.1上面實測是ok的。 2014 / 11 / 21  重點如下: 光碟要用EFI模式開機 硬碟中要有一個EFI分割區(至少35MB,不知道這個大小是否與系統有關) 硬碟分割的那個畫面, Device for bootloader installation 處,應指到2的EFl分割區(EFI boot partition) 根據資料來源的說明如下 *  VERY IMPORTANT STEP!!!  Near bottom of window,  "Device for bootloader installation"  should be the  EFI System Partition.  Select that one in the drop-down box. It will be a small (200-550MB) partition formatted as FAT32. It will likely be /dev/sda1 or /dev/sda2; but double-check that to be sure. 註1:硬碟分割的那個畫面,如果沒有EFI分割區,按下一步時系統會...