![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Cannot redirect ouput????? | minifish | Shell Programming and Scripting | 3 | 02-20-2008 12:15 PM |
| Identifying same character and ouput the sum | Raynon | Shell Programming and Scripting | 12 | 03-21-2007 11:59 PM |
| capture the ouput! | azmathshaikh | Shell Programming and Scripting | 0 | 12-20-2005 07:23 AM |
| Red Hat - ouput capture | juxtaman | UNIX for Dummies Questions & Answers | 3 | 04-10-2003 11:31 AM |
| Locating files and directing ouput | klannon | Filesystems, Disks and Memory | 2 | 03-11-2002 12:57 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Wrong Ouput when using printf under SFU
I used printf to print the following under SFU,
lrs=`cat lrs` hrs=`cat hrs` tp=`cat tp` printf “\n\n%5sM = $lrs Ohms%5sX = $hrs Ohms%5sT = $tp %%\n\n\n” > file cat file With the above script, I used %% after $tp only as a percentage sign and I get only the following output: % T = value of tp Any suggestions? |
|
||||
|
Quote:
I tried your suggestion as follows: a=1 b=2 c=3 Printf ‘ M = %s Ohms X = %s Ohms T = %s %%’ $a $b $c The above format worked fine but when a Command Substitution is used to set the Variables, I noticed that it does not give the right output. I did the following: #value of lrs = 710 lrs=`cat lrs` #value of hrs = 910 hrs=`cat hrs` #value of tp = 3 tp=`cat tp` printf ‘\n\nM = %s Ohms X = %s Ohms T = %s %%\n\n\n’ $lrs $hrs $tp The output is: %hms T = 310 The desired output should be: M = 710 Ohms X = 910 Ohms T = 3 % |
|
||||
|
Quote:
Sorry, it was just a typographical error from my last message regarding those odd single quotes but in my script they are actually straight quotes. Anyway, I had to do the following long and tedious way just to produce the right output: Printf '\n\t\t\b\b\bRmin = %s\t\t\t\t\b\b\b\b\b\b\b\bOhms Rmax = %s\t\t\t\t\t\t\b\b\b\b\bOhms Tilt = %s\t\t\t\t\t\t\t\t\b\b\b\b%%' $lrs $hrs $tp Output: Rmin = 710 Ohms Rmax = 910 Ohms Tilt = 3 % From the above printf statement, I noticed that if I use two or more variables, the numeric & non-numeric variables overwrite each other depending on their length. I need the non-numeric characters in my variables so I can’t remove those. Thus, I had to utilize series of tab and backspace characters so it would get the desired output. Is there an easier way to do this? |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|