从unix中的ascii文件中搜索特定数字

时间:2018-04-03 09:06:44

标签: unix awk sed

我有一个包含下面的ascii文件,它还包含垃圾字符

15֯04 DF0002 6.212.6.2-8041104878701200000000001048787012 F100000000CR
150530803676875161200000000001184000 140000 000000001064 2001320000000000000204920C0000000000000000000000000000F 0000000000000000
15¦004515300500000058000 24610438037004028685066100610470205000000010437840000000010437840ROSS STORES #1326 PFLUGERVILLE US 531078660TX A 9100E9999995 1 908041A
15_R01 000000 210 594326132632853 000000000000 0 01326006848 000000000
15G04 DF0002 3 10.3-8041 104878702100000000001048787021 F100000000CR
15¾0558803712442423600000000010484000 000000 000000010437 2001320000000000000984960C0000000000000000000000000000F 0000000000000000
15².004515300500000041000 24610438037004028581778100610470205000000015150840000000015150840ROSS STORES #746 AUSTIN US 531078703TX A 9120E9999995 1 908041A
15‘h01 000000 210 594325974664671 000000000000 0 007460077542 000000000
15…J04 DF0002 2 12.2-8041 104878702700000000001048787027 F100000000CR
47qŒ004610430000000 0006407190 407190SOUTHLGCY 407190 3200320000 ALL 0
47õ£00461043000000 407190 4071900000 ALL 0
47¶Ñ004610430000000 0006461043 461043SOUTHBAMS 461043 4004330000 ALL 0
47v+00461043000000 461043 4610430000 ALL 0
47]004610430000000 1000472573 483074VI 483074 3200320000 ALL 0
47s³00461043000000 483074 4610430000 ALL 0
47¶Ó004610430000000 1000473675 489359PR 489359 4610430000 ALL 0
47h004610430000000 9000299347 ACQ GU 436424 436424 3200320000 ALL 0
47S00461043000000 436424 4610430000 ALL 0
47æ/004610430000000 9000447390 489359 VCR VROL 489359 4004350000 ALL 0
47Ÿ¬00461043000000- *** END OF VSS-100-W REPORT *** 0
46u¨004610430000009000299347001201804112017127 V1100W 9000299347ACQ GU 436424 NB000000000000436424 Y3200320000Y9999840000000 0
46t004610430000009000299347001201804112017127 V1100W 9000299347ACQ GU 436424 NB000000000000436424 Y4610430000Y9999840000000 0
47ëR004610430000001REPORT ID: VSS-100-W VISANET SETTLEMENT SERVICE PAGE: 1 0
478|00461043000000 REPORTING FOR: 9000299347 ACQ GU 436424 INTERNATIONAL SETTLEMENT SERVICE REPORT DATE: 10FEB18 0
47Ir00461043000000 WEEKLY SETTLEMENT REPORTING HIERARCHY LIST LAST CHANGE: 07MAY17 0
478ý00461043000000 SETTLEMENT CURRENCY: USD 0

我想搜索以15开头的文件中的记录。如何使用awk或sed命令?有人能帮助我吗

1 个答案:

答案 0 :(得分:1)

的grep

grep '^15' file

AWK

awk '/^15/ { print $0 }' file

SED

sed -n '/^15/p' file