|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Duplicate a line n times
I want a command equivalent to Code:
sed 'p;p' file My input file contains Code:
1 2 3 If i want to input file like this Code:
1 1 1 2 2 2 3 3 3 I use Code:
sed 'p;p' file But if i want to duplicate lines for n no of times (for eg. 50) i cant give like this Code:
sed 'p;p;p..............;p' file so i need a simpler command in sed or awk Code:
My shell is csh |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Try like.. Code:
awk '{while(++i<3)print;i=0}' test.txt---------- Post updated at 03:37 AM ---------- Previous update was at 03:36 AM ---------- One more Code:
paste -d '\n' $(yes test.txt|head -5) |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Similarly: Code:
awk '{for(i=1; i<=n; i++) print}' n=50 fileLast edited by Scrutinizer; 01-23-2013 at 05:03 AM.. |
| The Following User Says Thank You to Scrutinizer For This Useful Post: | ||
nsuresh316 (01-23-2013) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tabbing a line a variable number of times in shell | chu816 | Shell Programming and Scripting | 4 | 03-01-2012 09:39 AM |
| Find string multiple times, same line | jgrosecl | UNIX for Dummies Questions & Answers | 7 | 07-11-2011 02:33 PM |
| AWK Duplicate lines multiple times based on a calculated value | jamesfx | Shell Programming and Scripting | 2 | 06-28-2011 08:18 AM |
| printing each line in a file X times | Autumn Tree | Shell Programming and Scripting | 4 | 05-10-2010 06:01 PM |
| matching multiple times in same line | oldtrash | Shell Programming and Scripting | 2 | 04-28-2004 05:57 PM |
|
|