AIX Unix Replicate data referencing a variable

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am using unix on AIX.
I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.
Example with 2 rows.
Product Number|Pick Qty|Unit of Issue|
13011|5|C|
566666|2|I|
The result I am after, is to use the Pick Qty value as the multiplying variable.
(This Pick Qty value will always be within the same position within the file, or column within a table.)
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
566666|2|I|
566666|2|I|
text-processing
add a comment |Â
up vote
0
down vote
favorite
I am using unix on AIX.
I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.
Example with 2 rows.
Product Number|Pick Qty|Unit of Issue|
13011|5|C|
566666|2|I|
The result I am after, is to use the Pick Qty value as the multiplying variable.
(This Pick Qty value will always be within the same position within the file, or column within a table.)
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
566666|2|I|
566666|2|I|
text-processing
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am using unix on AIX.
I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.
Example with 2 rows.
Product Number|Pick Qty|Unit of Issue|
13011|5|C|
566666|2|I|
The result I am after, is to use the Pick Qty value as the multiplying variable.
(This Pick Qty value will always be within the same position within the file, or column within a table.)
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
566666|2|I|
566666|2|I|
text-processing
I am using unix on AIX.
I want to know if there is a way in which I can replicate rows of data either within an existing file or reading from file a and results into file b, or within a temp table by a "variable" number of times.
Example with 2 rows.
Product Number|Pick Qty|Unit of Issue|
13011|5|C|
566666|2|I|
The result I am after, is to use the Pick Qty value as the multiplying variable.
(This Pick Qty value will always be within the same position within the file, or column within a table.)
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
13011|5|C|
566666|2|I|
566666|2|I|
text-processing
edited May 10 at 5:21
Debian_yadav
8342522
8342522
asked May 10 at 2:02
Christian
11
11
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
try
awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b
where
-F|use|as separator (you must escape it)NR==1 printprint header (first line)NR>1for(i=$2;i>0;i--) printfor all remaining line, print then$2time.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
try
awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b
where
-F|use|as separator (you must escape it)NR==1 printprint header (first line)NR>1for(i=$2;i>0;i--) printfor all remaining line, print then$2time.
add a comment |Â
up vote
1
down vote
try
awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b
where
-F|use|as separator (you must escape it)NR==1 printprint header (first line)NR>1for(i=$2;i>0;i--) printfor all remaining line, print then$2time.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
try
awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b
where
-F|use|as separator (you must escape it)NR==1 printprint header (first line)NR>1for(i=$2;i>0;i--) printfor all remaining line, print then$2time.
try
awk -F| 'NR==1 print NR>1for(i=$2;i>0;i--) print' file_a > file_b
where
-F|use|as separator (you must escape it)NR==1 printprint header (first line)NR>1for(i=$2;i>0;i--) printfor all remaining line, print then$2time.
answered May 10 at 7:15
Archemar
18.9k93365
18.9k93365
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442901%2faix-unix-replicate-data-referencing-a-variable%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password