can anybody help me out in writing the script for incrementing the specific field


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers can anybody help me out in writing the script for incrementing the specific field
# 1  
Old 08-05-2008
can anybody help me out in writing the script for incrementing the specific field

can anybody help me out in writing the any script (awk,shell or perl script) for incrementing the specific field highlighted below

/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[1]/dailyCount[1],........./{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[100]/dailyCount[1]


It should be in below format in oneline seperated by commas

/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[1]/dailyCount[1],/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[2]/dailyCount[1]........upto 100

Thanks In Advance :-)

# 2  
Old 08-05-2008
With shells that expand {} (ksh93, not ancient bash, zsh):

Code:
printf "/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[%d]/dailyCount[1]," {1..100}

Or with Z-Shell:

Code:
print -- '/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{['{1..100}']/dailyCount[1],'

If the last comma and the missing new line are problematic:

Code:
printf "/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[%d]/dailyCount[1]\n" {1..100} |
  paste -sd,

If you don't have those shells use some other tool:

Code:
perl -le'
  push @_, "/{[1]/data[1]/{[1]/assetMetricsList[1]/[[1]/{[".++$i."]/dailyCount[1]" 
    for 1..100;
    $, = ",";
    print @_'

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing specific and incrementing lines of text from file via variable

This is part of a larger script where I need to pass only 1 line of a file to the script, based on a variable and not a direct reference. As part of a for loop : # for((line=0;line<50;line++)); do # awk ‘NR==$line' PhraseList.txt; done ... (5 Replies)
Discussion started by: Seth
5 Replies

2. Shell Programming and Scripting

Need help writing array for the specific need of shell script

I need shell script for the following specfic need, I'll get following output after running my program. I wanted every 50th row in the coloumn and take into array. For example input ============== 03 03 03 03 05 05 05 05 07 07 07 07 I wanted to extract 3,5,7 and store it in... (12 Replies)
Discussion started by: JITHENDER
12 Replies

3. Shell Programming and Scripting

How to print with awk specific field different from specific character?

Hello, i need help with awk. I have this file: cat number DirB port 67 er_enc_out 0 er_bad_os 0 DirB port 71 er_enc_out 56 er_bad_os 0 DirB port 74 er_enc_out 0 er_bad_os 0 DirB port 75 ... (4 Replies)
Discussion started by: elilmal
4 Replies

4. Shell Programming and Scripting

Help with incrementing data in some field

Hi I have the below set of lines , i need to duplicate these lines 1000 times, also eevrytime when it is incremented , it should increment the one in Blue color. 130400030000010000200001 130400030000010000200002 140050030000010000200005A eg: 130400030000010000200001... (5 Replies)
Discussion started by: santhoshks
5 Replies

5. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

6. Shell Programming and Scripting

AWK SCRIPT HELP : INCREMENTING PROBLEM

Hi Guys , I am having one command file like this FILE1 ################################ awk '/output/ {a=$2} {for(i=1;i<=NF;i++) { gsub("i1", i) ; gsub("i2",++i) ; gsub("P1", p) }}1' output >> out9 awk '/output/ {a=$2} {for(i=1;i<=NF;i++) { gsub("i1", i) ;... (2 Replies)
Discussion started by: jaita
2 Replies

7. Shell Programming and Scripting

Need help in writing a script to create a new text file with specific data from existing two files

Hi, I have two text files. Need to create a third text file extracting specific data from first two existing files.. Text File 1: Format contains: SQL*Loader: Release 10.2.0.1.0 - Production on Wed Aug 4 21:06:34 2010 some text ............so on...and somwhere text like: Record 1:... (1 Reply)
Discussion started by: shashi143ibm
1 Replies

8. Shell Programming and Scripting

help writing rm script excluding specific titled dir

I am attempting to write a housecleaning script that does the following: 1) goes to a specific directory 2) deletes all contents of that directory but a specific directory within it. So my users all keep and use the Shared directory in OSX. Within /Users/Shared there are also standard named... (1 Reply)
Discussion started by: nomados
1 Replies

9. Shell Programming and Scripting

writing string to specific line

I want to put a text string in file using any method on specific line line number 30 text to be put %this is location /var/www/filename (3 Replies)
Discussion started by: aliahsan81
3 Replies

10. HP-UX

extract field of characters after a specific pattern - using UNIX shell script

Hello, Below is my input file's content ( in HP-UX platform ): ABCD120672-B21 1 ABCD142257-002 1 ABCD142257-003 1 ABCD142257-006 1 From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could... (2 Replies)
Discussion started by: jansat
2 Replies
Login or Register to Ask a Question