The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cannot get logic for concatenation awk user_prady Shell Programming and Scripting 7 12-10-2007 03:09 AM
File Concatenation samit_9999 UNIX for Dummies Questions & Answers 3 11-21-2006 06:26 AM
string concatenation systemsb UNIX for Dummies Questions & Answers 7 04-04-2006 12:03 PM
Implementing Concatenation(cat) toughguy2handle High Level Programming 2 09-22-2005 02:10 AM
Concatenation videsh77 Shell Programming and Scripting 2 12-14-2004 06:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-04-2007
Asteroid Asteroid is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 38
Concatenation

How can I do this:

date = 4 -----------> 04
Month= 3-----------> 03

I wish to make a varibale named Var1 which will hold the value of current date and month value as:

2 digits for date.
2 digits for month.

So finally var1 should hold value as 0403 --- MMDD
  #2 (permalink)  
Old 04-04-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Code:
var1=$( printf "%02d%02d" $date $Month )
  #3 (permalink)  
Old 04-04-2007
Asteroid Asteroid is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 38
But it is prompting syntax error...
Code:
$DB_Date=$(printf "%02d%02d", $date, $Month );
  #4 (permalink)  
Old 04-04-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by Asteroid
But it is prompting syntax error...
Code:
$DB_Date=$(printf "%02d%02d", $date, $Month );
That is the syntax used in shell script.
Try this
Code:
$DB_Date=sprintf("%02d%02d", $date, $Month);
  #5 (permalink)  
Old 04-04-2007
Asteroid Asteroid is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 38
Code:
$DB_Date=sprintf("%02d%02d", $date, $Month);
$DB_Date=printf("%02d%02d", $date, $Month);

I have previously tried the above....

But It gives out 0000 ...

Really I am lost how it could be possible in PERL.
  #6 (permalink)  
Old 04-04-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Can you show your full code?
  #7 (permalink)  
Old 04-04-2007
Asteroid Asteroid is offline
Registered User
  
 

Join Date: Apr 2007
Posts: 38
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);

open (dbfile, "/data1/scp/store/DB/0403/SCP_PP_SUBS.dat") or die "Couldn't get at THE FILE";

@data;
$credit;
$count =0;



          print "DB_Date:: $DB_Date \n\n";                       
          print "LESS then the 100 Credit $day/$month/$year\n\n";  
           print "-------------------------------------------\n";

 while (<dbfile>) 
 {
         ........................
         ..........................
         ............................
         ...........................

 Do some file parsing operation

}

print "Total Count: $count \n";
close dbfile;
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0