Sponsored Content
Top Forums Shell Programming and Scripting Increment Column having Alphanumeric value in file Post 302943079 by ketanraut on Tuesday 5th of May 2015 08:33:27 AM
Old 05-05-2015
Thanks Scrutinizer,this is what m looking for.

I have done some changes as required in script, but awk give me errors while calling parameters.I have tried with " ' ' " but its not working...any suggestion?
Code:
awk -v U=0 -v L=0 -v n=$number 'BEGIN{for(i=1; i<=n; i++) printf ''"$u_id"'%04d|'"$u_loc"'|'"$u_pkg"'|bocvdf|'"$u_cmmac"'%04d\n', U++, L++}' >> dataspecific_$(date '+%d%m%Y%H%M')


ERRORS :
Code:
awk: BEGIN{for(i=1; i<=n; i++) printf AAAAAA%04d|LLLLLL|OKLN SSDD|bocvdf|BBBBBB%04d\n, U++, L++}
awk:                                                    ^ syntax error
awk: BEGIN{for(i=1; i<=n; i++) printf AAAAAA%04d|LLLLLL|OKLN SSDD|bocvdf|BBBBBB%04d\n, U++, L++}
awk:                                                                               ^ backslash not last character on line
+ awk -v U=0 -v L=0 -v n=10 'BEGIN{for(i=1; i<=n; i++) printf "$u_id"%04d'
+ '"$u_pkg"'
+ docsis
./case.sh: line 11: "$u_pkg": command not found
./case.sh: line 11: bocvdf: command not found
+ '"$u_loc"'
./case.sh: line 11: "$u_loc": command not found
+ '"$u_cmmac"%04dn, U++, L++}'
date '+%d%m%Y%H%M')
awk: cmd. line:1: BEGIN{for(i=1; i<=n; i++) printf "$u_id"%04d
awk: cmd. line:1:                                             ^ unexpected newline or end of string


Last edited by ketanraut; 05-05-2015 at 09:37 AM.. Reason: Updating Information..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Increment a column using awk

Hi, I have a sample file like below: 213~!0~!Feb 16 2009 4:57:29:833PM~!0 212~!0~!Feb 7 2009 5:29:57:760PM~!0 211~!0~!Feb 4 2009 5:51:40:863PM~!0 209~!0~!Dec 17 2008 3:19:05:043PM~!0 206~!0~!Dec 4 2007 4:01:02:850PM~!0 "~!" is the field seperator. I need to replace the... (5 Replies)
Discussion started by: h_banka
5 Replies

2. Shell Programming and Scripting

Check file and increment

My scripts excepts 4 files ABCD_01 ABCD_02 ABCD_03 ABCD_04 I want to check for these files , and increment counter one by one . at the end i would like to echo as 4 of 4 expected instances of file found . I tried something like thsi $counter =1 if counter=counter+1 i need... (5 Replies)
Discussion started by: ultimatix
5 Replies

3. Shell Programming and Scripting

File existence and increment

count=0; while read line; do ] && let count=count+1; done < file_name.txt echo echo "$count of 10 files found " echo The scenario is a follows : I have a file which contains a list of filenames present in particular directory . I am checking fo the existence of the file and... (5 Replies)
Discussion started by: ultimatix
5 Replies

4. Shell Programming and Scripting

Searching Alphanumeric Character From a File

Hi, In a error log file, the error code of a particular error contains both Alphabet and Numbers. My problem statement is to find the error codes from a particular log. That means, I need to search a word, which contains both alphabet and number. Please help me. Below is two examples of error... (1 Reply)
Discussion started by: snehasish_jana
1 Replies

5. Shell Programming and Scripting

Increment Numbers in File

Hello, I have a text file withe some records 20121031|5 20121030|3 20121029|1 20121028|4 20121027|6 I want to search for a patten with '20121030' and then increment the second part of the delimiter i.e. 3 by 1 to make it 4 to look like 20121031|5 20121030|4 20121029|1 20121028|4... (7 Replies)
Discussion started by: pparthiv
7 Replies

6. Shell Programming and Scripting

Increment existing column in file

Hi All, I have a file with 3 millions records in which 3rd column is same throughout say its value is 0 throughout.for example: Col1 Col2 Col3 Col4 A 1 0 5 B 2 0 6 C 3 0 7 D 4 0 9 I want my output as : Col1 Col2 Col3 Col4 A 1 ... (4 Replies)
Discussion started by: Pinky456
4 Replies

7. UNIX for Dummies Questions & Answers

Want to sort a file which contains alphanumeric strings

I want to sort a file which contains alphanumeric string. bash-3.00$ cat abc mtng1so mtng2so mtng11so mtng9so mtng23so mtng7so hstg2so hstg9so hstg1so hstg11so hstg13so bash-3.00$ Want output like this, using one liner. hstg1so (1 Reply)
Discussion started by: Raza Ali
1 Replies

8. Shell Programming and Scripting

Create new file with increment column based on conditions

Hello, Using bash script, i need to process the following file: 887,86,,2013-11-06,1,10030,5,2,0,200,, 887,86,,2013-11-05,1,10030,5,2,0,199,, 887,138,,2013-11-06,1,10031,6,2,0,1610612736,, 887,164,,2013-11-06,1,10000,0,2,0,36000,, and to create a new file such as the below ... (2 Replies)
Discussion started by: JonhyDeep
2 Replies

9. Shell Programming and Scripting

Check increment values in column

Gents, I have a file where i would like to check the constant increment by 2 in column 2. 5450 1000 5450 1002 5450 1004 5450 1006 5465 1000 5465 1002 5465 1006 5465 1008 5550 1002 5550 1004 5550 1006 5550 1008 6830 1000 6830 1002 6830 1008 6830 1010 (6 Replies)
Discussion started by: jiam912
6 Replies

10. Shell Programming and Scripting

Moving alphanumeric files according to the digit in file name

This is the content of my directory c_g_se1_gb.ph c_g_se1_gb.ph_pl_s.t c_g_se1_gb.ph_pl_tr.t c_g_se3_gb.ph c_g_se3_gb.ph_pl_s.t c_g_se3_gb.ph_pl_tr.t c_g_se2_gb.ph c_g_se2_gb.ph_pl_s.t c_g_se2_gb.ph_pl_tr.t c_g_se4_gb-1.ph c_g_se4_gb-1.ph_pl_s.t c_g_se4_gb-1.ph_pl_tr.t... (9 Replies)
Discussion started by: sammy777888
9 Replies
All times are GMT -4. The time now is 02:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy