Sponsored Content
Full Discussion: Repeat using for loop
Top Forums Shell Programming and Scripting Repeat using for loop Post 302563443 by ygemici on Tuesday 11th of October 2011 08:59:50 AM
Old 10-11-2011
Code:
# awk -F, 'NR==1{print}NR>1{split($2,a,"-");x=a[NF];i=1;while(i<=NF){for(j=1;j<NR-1;j++);
{printf "%s,%s-%s-%s-%s-%d,%s,%s\n",$1,a[i++],a[i++],a[i++],a[i++],x+j,$3,$4}}}' infile
2011-10-10 10:46:00,1-1-13-1-1,151510,ALCLA0A84D2C
2011-10-10 10:46:00,1-1-13-1-2,151520,65537
2011-10-10 10:46:00,1-1-13-1-3,151515,46932
2011-10-10 10:46:00,1-1-13-1-4,151521,32769
2011-10-10 10:46:00,1-1-13-1-5,151522,32769
2011-10-10 10:46:00,1-1-13-1-6,151518,167
2011-10-10 10:46:00,1-1-13-1-7,151523,-183
2011-10-10 10:46:00,1-1-13-1-8,151517,2
2011-10-10 10:46:00,1-1-13-1-9,151512,3FE51469AAAA01
2011-10-10 10:46:00,1-1-13-1-10,151513,BVM5400CRAO00240VA
2011-10-10 10:46:00,1-1-13-1-11,151519,11984
2011-10-10 10:46:00,1-1-13-1-12,11124,0
2011-10-10 10:46:00,1-1-13-1-13,151516,0
2011-10-10 10:46:00,1-1-13-1-14,151514,0
2011-10-10 10:46:00,1-1-13-1-15,121255,4673
2011-10-10 10:46:00,1-1-13-1-16,121256,333
2011-10-10 10:46:00,1-1-13-1-17,121254,50
2011-10-10 10:46:00,1-1-13-1-18,121257,16
2011-10-10 10:46:00,1-1-13-1-19,151511,WILDCARD

regards
ygemici
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Repeat a command in a shell

Hi there, i would like to repeat a command in a shell sript (bash) the script starts with a menu to choose a menu point to do something .... on the end of the script i would like to restart the programm to choose the menu points on the beginning. I would also make a sript that send... (2 Replies)
Discussion started by: scotty
2 Replies

2. UNIX for Dummies Questions & Answers

any idea to repeat a action in VI

Any idea to repeat an action to all the lines in vi... suppose i want to delete the first word from all the lines in VI .. how would i do it ? in general i am also looking for a way to apply a action to all the lines in VI . (6 Replies)
Discussion started by: myelvis
6 Replies

3. UNIX for Dummies Questions & Answers

Repeat Commands

On my system I use Escape "k" to go back in commands. I read on tutorials that it is ctrl p, but that does not work on my system. Anyone know what the command to go foward is? (6 Replies)
Discussion started by: dereckbc
6 Replies

4. Shell Programming and Scripting

to copy and repeat

Hi All, I have done some looking at other threads but haven't found quite what I am looking for. I am a newbie to scripting and haven't got to where I want to you but here is my basic question. I have a script to copy a file and send it to another file with a date and time stamp. What I want to... (4 Replies)
Discussion started by: falcondown01
4 Replies

5. UNIX for Dummies Questions & Answers

repeat each record n times

I have: aa01 aa02 aa03 aa04 ab01 ab02 ab03 ab04 I would like each record printed 5 times: aa01 aa01 aa01 aa01 aa01 aa02 aa02 (6 Replies)
Discussion started by: kenneth.mcbride
6 Replies

6. Shell Programming and Scripting

case loop... repeat on bad input?

I'm trying to get a case statement to start over if an undefined option is selected... But I am ata loss on how to actually do it. Here is a quick example of what I have. Echo "1) do this/n 2) Do that/n 3) Quit/n Make a selection/n" Read answer Case answer in 1) Dothid;; 2) Dothat;;... (3 Replies)
Discussion started by: trey85stang
3 Replies

7. Shell Programming and Scripting

Ping and repeat ?

How do i write a loop ping to see if it get timeout or hang ? it should loop every 30 second to ping a server ? ping -c 5 -t 15 www.google.com if ]; then date '+%Y-%m-%d %H:%M:%S Connection Unavailable' >> /home/sabercats/checkconnection.log else date '+%Y-%m-%d %H:%M:%S Connection... (3 Replies)
Discussion started by: sabercats
3 Replies

8. Homework & Coursework Questions

How to use loop to repeat task?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. How can i use loop to repeat task. 2.shirt=15 black=13.50 echo "how many shirt you want" read num echo echo "Please enter a choice" echo "1 ---> normal... (5 Replies)
Discussion started by: Tauatioti
5 Replies

9. Shell Programming and Scripting

Repeat for different variable

Hey, I've created following script: var1=test1 setA=testA if ... touch $setA/$var1 ... fi I would like now the repeat the command touch (in this example) for different variables. So below, the varX should run 3 times (var1, var2, var4). Var3 is skipped in this example... (4 Replies)
Discussion started by: brononius
4 Replies

10. Homework & Coursework Questions

How to use xargs to repeat as a loop to grab date string?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: My goal to find how many requests in 14 days from weblog server. I know to cat a weblog file to wc -l to find the... (8 Replies)
Discussion started by: scopiop
8 Replies
All times are GMT -4. The time now is 03:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy