more ml.awk begin{ FS="," } { print( $2) } more ml.txt zhangsan,lisi,wangwu awk -f ml.awk ml.txt 显示 想要 得到 lisi 但显示结果为: zhangsan,lisi,wangwu 好像awk中的分割符定义没有起任何作用, 若将文本中的换为zhangsan lisi wangwu 又可以正常使用了 请兄弟们帮忙看看,错在那里?? :em02::em02::em02:
$ cat test.txt a#@||@#b#@||@#c#@||@#x#@||@#|| d#@||@#e 1#@||@#3#@||@#5 a#@||@#1#@||@#2#@||@#3#@||@#4#@||@#x#@||@#|| a#@||@#f#@||@#r#@||@#t#@||@#x#@||@#|| 4#@||@#5 $ awk -F"#@||@#" '{print $1}' test.txt a d 1 a a 4 $ awk -F"#@||@#" '{print $2}' test.txt | | | | | | $ awk -F"#@\|\|@#" '{print $2}' test.txt | | | | | | $ awk -F'#@||@#' '{print $2}' test.txt | | | | | | $ awk 'BEGIN{FS="#@||@#"}{print...
符号作为文件的分割符。 字符:"" 对应十六进制为0x0F,在AIX中vi显示成^O 。 AIX操作系统下我查看一个文件的列数如下是可以实现的 awk -F"" '{print NF}' 1.del | more 将上面的脚本拷贝的aix界面,执行是好的。 请问有没更好的办法可以是实现?如何进行转义?
awk 按照awk的说明 awk默认分割符为 空格和 tab awk '{pring $1,$2,$3}' myfile 这时可以看到正确输出 但是按照awk自行设置多个分割符的方法: awk -F'[ \t]' '{pring $1,$2,$3}' myfile 这时无法正确显示 此时只有$1有内容, $2,$3看不到任何输出,不知道哪里出了问题,望高人指点,谢谢
如下列 SPNT 64051 51.21348477.24522281.41 33. VELF 64051 0 20 1569 40 1571 60 1583 80 1595 100 1607 VELF 120 1619 140 1632 160 1645 180 1659 200 1672 分割符有. 和长度不同的空格 请问 我在gawk里应该怎么写呀?? BEGIN{FS="[ |\\.]"} 不对呀 [ 本帖最后由 lmd96168 于 2006-11-16 12:46 编辑 ]
test.txt a|||a|||d b|||s|||d awk 'BEGIN{FS="|||";}{print $1}' test.txt 输出: a b 感觉正常 但是 awk 'BEGIN{FS="|||";}{print $2}' test.txt 输出竟然是两行空白,而不是预想的 a s 不知问题出在哪里了? (solaris 2.7 awk版本: 惭愧,不知道怎么看 哪位大侠顺便指点)
比如 Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 68547636 28878604 36186948 45% / /dev/sda2 34898084 134028 32991284 1% /backup /dev/sda1 101089 15111 80759 16% /boot none 512588 0 512588 0% /dev/shm 希望读到 其中45% %1 等参数 而后做判断, 但是 使用 df|awk -F'[ %]' '{print $5...
awk -F "AND|NOT|OR" '{print $1}' filename PHP中 explode("AND|NOT|OR",$filename) 这样无法实现
[code] $ cat test.txt 001a-4ba4-37f1 101 Learned GigabitEthernet0/24 AGING [/code] 原来的test.txt内容 [code] awk -F"[-/]" '{print $1,$2,$3,$4}' test.txt 001a 4ba4 37f1 101 Learned GigabitEthernet0 24 AGING [/code] 使用正则表达式,使用-或/作为分隔符 [code] $ awk -F"[ /]" '{print $1,$2,$3,$4}' test.txt 001a-4ba4-37f1 101 [/code] 使用空格或/作为分隔符,没...