Concatenation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Concatenation
# 8  
Old 04-04-2007
Code:
$year=$year+1900;
$DB_Date=sprintf("%02d%02d", $date, $Month);

# 9  
Old 04-04-2007
But the output is same...

print $DB_Date ---> 0000

I see the following warning ..

Code:
Use of uninitialized value in sprintf at /dev/fd/4 line 9


Last edited by Asteroid; 04-04-2007 at 06:22 AM..
# 10  
Old 04-04-2007
Code:
#!/bin/perl -w
use IO::Handle;

($day, $month, $year) = (localtime)[3,4,5];


$month=$month+1;
$year=$year+1700;
$DB_Date=printf("%02d%02d", $date, $Month);

Use day instead of date.Variables are case sensitive.Change the case of month
# 11  
Old 04-04-2007
THx man ,, It worked ,, ...... Smilie

Your help was really appriciating..
# 12  
Old 04-04-2007
Asteroid, as a side note, get familiar with the use strict; pragma to avoid that $month $Month situation.

From the Perl traps for the unwary page at http://www.perl.com/doc/manual/html/pod/perltrap.html
Quote:
The second biggest trap is not making your entire program runnable under use strict.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Concatenation script

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

File concatenation

awk '{$2=$2":"$8"-"$3;$3=$NF;$4=$NF="";print $0 | $10=$10":"$8"-"$18;$11=$NF;$12=$NF="";print $0 }' design.txt Trying to concatenate specific fields in a spreadsheet and the others remain unchanged. I attached an excel spreadsheet (all the data comes from a design.txt), but I put an example... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Help with String concatenation

I have a script which is migrated from AIX to Linux & now while running it is no able to concatenate string values The string concatenation step under while loop is not displaying desired result Please find below the piece of code: while read EXT_FILE ; do EXT_FILE=$EXT_FILE.ext.sent echo... (7 Replies)
Discussion started by: PreetArul
7 Replies

4. Shell Programming and Scripting

Line concatenation help

please help me on this.... cat /xx.txt 2:1 2 2:2 24 8:0 0 9:0 0 Expected result would be 2:1 2 2:2 24 8:0 0 9:0 0 (4 Replies)
Discussion started by: Aditya.Gurgaon
4 Replies

5. Shell Programming and Scripting

Concatenation of two patterns

Read the lines from the file and concatenate the lines into single line then search the string "INPUT=" from the another file and if "INPUT" is present in that file assign the concatenate patterns into "INPUT=" pattern. example: file1.txt <some lines> INPUT = <some lines> file2.txt... (3 Replies)
Discussion started by: krsureshmca
3 Replies

6. Shell Programming and Scripting

String concatenation

Hi, I have two files. cat file.txt a b c d cat file1.txt j k l m I need the output as a:j (12 Replies)
Discussion started by: nareshkumar522
12 Replies

7. UNIX for Dummies Questions & Answers

grep concatenation??

So, I have huge results file and I need to extract two lines, so far I know that these two commands separately do what I need: grep "Query=" results.out grep "Sequence" -2 results.out Now, I have no idea how to concatenate these results together so that every query matches up with their... (8 Replies)
Discussion started by: Iifa
8 Replies

8. UNIX for Dummies Questions & Answers

Concatenation Of Variables

Hi, when I echo the values of two variables that have been set for example: export FRUIT1=ORANGE export FRUIT2=APPLE echo $FRUIT1 ORANGE echo $FRUIT2 APPLE as expected but when I echo the following: echo ${FRUIT1}AND{$FRUIT2} I was expecting to get: ORANGEANDAPPLE but... (6 Replies)
Discussion started by: jaxim
6 Replies

9. Shell Programming and Scripting

String Concatenation

Hi All, I need to concatenate the values in the array into a variable. Currently the code is : for (( i=1 ; i <= $minCount ; i++ )) do var="${var}""${sample_file}" done The output is : /tmp/1/tmp/2/tmp/3/tmp/4/tmp/5/tmp/6/tmp/7/tmp/8/tmp/9/tmp/10 I need a space between... (1 Reply)
Discussion started by: sh_kk
1 Replies

10. Shell Programming and Scripting

Concatenation

What is syntax for String concatenation? I have $1 as directory. $var is some variable value '/' String value. How do I have to concatenate if I have to run utility - util $1 followed by '/' followed by $var There is no space between these three. (2 Replies)
Discussion started by: videsh77
2 Replies
Login or Register to Ask a Question