LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-13-2003, 09:45 AM   #1
gumby
LQ Newbie
 
Registered: May 2003
Posts: 5

Rep: Reputation: 0
Question bash printf anyone?


How would one format this string in printf?

"day2.20030308.d"

DIR=day2.20030308.d

I have been using:

awk '{printf '`echo $DIR`' "|%-17s|\n", $1}' reg <filename>

And get a parse error on the dot before the d . Does printf look at this as a regular string?
 
Old 05-13-2003, 10:00 AM   #2
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
Try:

echo $DIR | awk '{printf "|%-17s|\n", $1}'

Is that exit that you want?
 
Old 05-13-2003, 11:26 AM   #3
gumby
LQ Newbie
 
Registered: May 2003
Posts: 5

Original Poster
Rep: Reputation: 0
No.

I am trying to get the DIR variable to repeat in the left-hand column like so:

awk '{printf '`echo $DIR`' "|%-15s|\n", $1}' reg
0.200303|Maria |
0.200303|Christina |
0.200303|Nancy |
0.200303|Juan |
0.200303|Lourdes |
0.200303|Carlos |
0.200303|Mario |
0.200303|Malia |
0.200303|Eloisa |
0.200303|Josie |

DIR should contain "day2.20030303" not 0.20030303
 
Old 05-13-2003, 11:44 AM   #4
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
Then could be used:

DIR=2.200303

awk '{printf '$DIR' "|%-15s|\n", $1}' arq
2.2003|Maria |
2.2003|Christina |
2.2003|Nancy |
2.2003|Juan |
2.2003|Lourdes |
2.2003|Carlos |
2.2003|Mario |
2.2003|Malia |
2.2003|Eloisa |
2.2003|Josie |

I didn't understand if the $DIR is already what you have, but it can be modified if necessary ...
 
Old 05-13-2003, 11:51 AM   #5
gumby
LQ Newbie
 
Registered: May 2003
Posts: 5

Original Poster
Rep: Reputation: 0
That's getting closer to what I want. Thanks!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
is a printf wrapper possible? Thinking Programming 2 10-21-2005 07:44 AM
c printf question. fredgt Programming 5 09-09-2004 05:06 AM
More arguments in printf() AMMullan Programming 3 02-23-2004 02:29 PM
Using 'printf' on a 'struct' skywalker27182 Programming 10 12-20-2003 12:06 PM
printf new_user10 Programming 3 09-09-2003 11:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration