Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------
- |Data statistics|Number of|
- |-------------------------|
- |Records passed | 750,517|
- ---------------------------
- Transaction Data for Serial Numbers
- No of Records : 750517
- -----------------------------------------------------------------------------------------------------------
- |Material Number|Serial Number From |Serial Number To |Document Year|Delivery Document|Material Document|
- |----------------------------------------------------------------------------------------------------------
- |200965 |18604165309338 |18604165309387 |2012 |6100202749 |AAA2778202 |
- |201163 |10740000822407 |10740000822606 |2012 |6100202749 |AAA2778202 |
- |201232 |18604177741067 |18604177741366 |2012 |6100202749 |AAA2778202 |
- |201295 |18604221522337 |18604221523836 |2012 |6100202749 |AAA2778202 |
- |201480 |18604113309952 |18604113310131 |2012 |6100202749 |AAA2778202 |
- |201781 |18604199150436 |18604199150835 |2012 |6100202749 |AAA2778202 |
- |201480 |6001400030046472 |6001400030046771 |2012 |6100202520 |AAA2777953 |
- |202853 |6001700000180323 |6001700000180722 |2012 |6100202520 |AAA2777953 |
- -----------------------------------------------------------------------------------------------------------
- awk ' BEGIN {FS ="|"; OFS = ","} { if ($2~"2") print $2,$3,$4,$5,$6,$7 }' Input.txt
- 200965 ,18604165309338 ,18604165309387 ,2012 ,6100202749 ,AAA2778202
- 201163 ,10740000822407 ,10740000822606 ,2012 ,6100202749 ,AAA2778202
- 201232 ,18604177741067 ,18604177741366 ,2012 ,6100202749 ,AAA2778202
- 201295 ,18604221522337 ,18604221523836 ,2012 ,6100202749 ,AAA2778202
- 201480 ,18604113309952 ,18604113310131 ,2012 ,6100202749 ,AAA2778202
- 201781 ,18604199150436 ,18604199150835 ,2012 ,6100202749 ,AAA2778202
- 201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- 202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
- $ awk 'gsub(/|/,",") && gsub(/^,|,$/,"") && /^2/' file
- 200965 ,18604165309338 ,18604165309387 ,2012 ,6100202749 ,AAA2778202
- 201163 ,10740000822407 ,10740000822606 ,2012 ,6100202749 ,AAA2778202
- 201232 ,18604177741067 ,18604177741366 ,2012 ,6100202749 ,AAA2778202
- 201295 ,18604221522337 ,18604221523836 ,2012 ,6100202749 ,AAA2778202
- 201480 ,18604113309952 ,18604113310131 ,2012 ,6100202749 ,AAA2778202
- 201781 ,18604199150436 ,18604199150835 ,2012 ,6100202749 ,AAA2778202
- 201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- 202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
- $ awk 'gsub(/|/,",") && gsub(/^,|,$/,"") && $3~/^,600/' file
- 201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- 202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
- $ awk -F, 'gsub(/|/,",") && gsub(/^,|,$/,"") && $3~/^600/' file
- 201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- 202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
- $ awk -F"|" -v OFS="," '$2~/^2/ {NF--; $0=$0; print}' file
- ,200965 ,18604165309338 ,18604165309387 ,2012 ,6100202749 ,AAA2778202
- ,201163 ,10740000822407 ,10740000822606 ,2012 ,6100202749 ,AAA2778202
- ,201232 ,18604177741067 ,18604177741366 ,2012 ,6100202749 ,AAA2778202
- ,201295 ,18604221522337 ,18604221523836 ,2012 ,6100202749 ,AAA2778202
- ,201480 ,18604113309952 ,18604113310131 ,2012 ,6100202749 ,AAA2778202
- ,201781 ,18604199150436 ,18604199150835 ,2012 ,6100202749 ,AAA2778202
- ,201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- ,202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
- $ cat file
- ---------------------------
- |Data statistics|Number of|
- |-------------------------|
- |Records passed | 750,517|
- ---------------------------
- Transaction Data for Serial Numbers
- No of Records : 750517
- -----------------------------------------------------------------------------------------------------------
- |Material Number|Serial Number From |Serial Number To |Document Year|Delivery Document|Material Document|
- |----------------------------------------------------------------------------------------------------------
- |200965 |18604165309338 |18604165309387 |2012 |6100202749 |AAA2778202 |
- |201163 |10740000822407 |10740000822606 |2012 |6100202749 |AAA2778202 |
- |201232 |18604177741067 |18604177741366 |2012 |6100202749 |AAA2778202 |
- |201295 |18604221522337 |18604221523836 |2012 |6100202749 |AAA2778202 |
- |201480 |18604113309952 |18604113310131 |2012 |6100202749 |AAA2778202 |
- |201781 |18604199150436 |18604199150835 |2012 |6100202749 |AAA2778202 |
- |201480 |6001400030046472 |6001400030046771 |2012 |6100202520 |AAA2777953 |
- |202853 |6001700000180323 |6001700000180722 |2012 |6100202520 |AAA2777953 |
- -----------------------------------------------------------------------------------------------------------
- $ awk 's=$1~/^|2/{gsub(/^|||$/,""); gsub(/|/,",")}s' file
- 200965 ,18604165309338 ,18604165309387 ,2012 ,6100202749 ,AAA2778202
- 201163 ,10740000822407 ,10740000822606 ,2012 ,6100202749 ,AAA2778202
- 201232 ,18604177741067 ,18604177741366 ,2012 ,6100202749 ,AAA2778202
- 201295 ,18604221522337 ,18604221523836 ,2012 ,6100202749 ,AAA2778202
- 201480 ,18604113309952 ,18604113310131 ,2012 ,6100202749 ,AAA2778202
- 201781 ,18604199150436 ,18604199150835 ,2012 ,6100202749 ,AAA2778202
- 201480 ,6001400030046472 ,6001400030046771 ,2012 ,6100202520 ,AAA2777953
- 202853 ,6001700000180323 ,6001700000180722 ,2012 ,6100202520 ,AAA2777953
Add Comment
Please, Sign In to add comment