I than mixed the codes I found on these sites together to make something below:
I am by no means an expert Bash scripter however, once I started looking at the code I was able to roughly figure out how this worked. Obviously this code be improved upon but this serves my purpose for now.
in csh I was using:
set prompt=""$HOSTNAME".tk.\!> "
to customize the look of my prompt. I have seen the light after reading the perils of csh scripting and wish to switch to bash. How do I customize my bash prompt??? I've tried many variation of the above w/no success, and searching this... (2 Replies)
hi experts,
i just need a help that my script is generating the output which i will mentioned below but the fileds are not justified the alignment is disturbed.
0 8718 8718 0 8777
1 7450 7450 0 7483
2 5063 5063 0 5091
3 3840 3840 0 3855
4 ... (2 Replies)
I'm trying to use unison from bash on windows with cygwin. I don't know if this is a cygwin question, bash question or unison question. Since I always get reprimanded by the cygwin mailing list for assuming it is a cygwin problem, I'll assume it is a bash question.
The following commands work... (7 Replies)
It looks like,
user@hostname:/auto/home3/user$
Desired,
user@hostname$
I added following line in .bashrc, but still its same.
export PS1=" $ "
Please help me :confused: (13 Replies)
Hi,
Does anyone know any way of making bash prompt extended with conditional content?
Example:
export PS1="] && echo '#' || echo '\$'" # This won't work - prompt is not executed
# export PS1="\$" # This is an existing but also working equivalent
I would like to use more complex... (8 Replies)
I'm using a custom prompt with PS1 in my .profile. It is
PS1="\\u@\e\:\W\ \\$\ \"
and it works well, as you can see,
http://content.screencast.com/users/killer54291/folders/Jing/media/2b3db52a-ebf7-43e2-95cc-f45dadbc2b98/00000023.png
but, when i type more than the width of the window, it... (0 Replies)
This is an instance of "if it's not one thing, it's another."
I recently fell victim to my own stupidity in trashing, by accident, my long-running and very highly-customized .bash_profile and .bashrc files for Cygwin & Cygwin/X. I had backups from a previous "go" with this, and decided to use... (0 Replies)
I am working with a script to simplyfy some operations where I work, but one of the programs needs me to enter a password.
It will as me "Please enter the administrator password:"
Is there a way to make a bash script to automatically answer the question with the needed password?
I am looking... (3 Replies)
Hi,
I'm trying to run a program from the bash prompt and I don't understand why it is returning with an error.
Dig is my C program, and it takes in parameters J4, detect, 3 and 0182F98E
var1="cygdrive/c/2i/test fixture/software/mccdaqtest/debug/Dig J4 detect 3 0182F98E"
when I do
... (6 Replies)
Hello Guys,
I have facing problem with linux shell prompt .Am expecting my Bash prompt to be like below
but its showing like
~]$ ot@Servername and while typing the commands the prompt looks like below:
~]$ echo $PS1
$
~]$ ot@ServernameChecked the .bash_profile and also changed... (9 Replies)
Discussion started by: kapil514
9 Replies
LEARN ABOUT PHP
money_format
MONEY_FORMAT(3) 1 MONEY_FORMAT(3)money_format - Formats a number as a currency stringSYNOPSIS
string money_format (string $format, float $number)
DESCRIPTION money_format(3) returns a formatted version of $number. This function wraps the C library function strfmon(3), with the difference that
this implementation converts only one number at a time.
PARAMETERS
o $format
- The format specification consists of the following sequence:
oa
% character
ooptional flags
ooptional field width
ooptional left precision
ooptional right precision
oa required conversion character
Flags
One or more of the optional flags below can be used:
o = f - The character = followed by a (single byte) character f to be used as the numeric fill character. The default
fill character is space.
o ^ - Disable the use of grouping characters (as defined by the current locale).
o + or ( - Specify the formatting style for positive and negative numbers. If + is used, the locale's equivalent for +
and - will be used. If ( is used, negative amounts are enclosed in parenthesis. If no specification is given, the
default is +.
o ! - Suppress the currency symbol from the output string.
o - - If present, it will make all fields left-justified (padded to the right), as opposed to the default which is for
the fields to be right-justified (padded to the left).
Field width
o w - A decimal digit string specifying a minimum field width. Field will be right-justified unless the flag - is
used. Default value is 0 (zero).
Left precision
o # n - The maximum number of digits ( n) expected to the left of the decimal character (e.g. the decimal point). It
is used usually to keep formatted output aligned in the same columns, using the fill character if the number of dig-
its is less than n. If the number of actual digits is bigger than n, then this specification is ignored. If group-
ing has not been suppressed using the ^ flag, grouping separators will be inserted before the fill characters (if
any) are added. Grouping separators will not be applied to fill characters, even if the fill character is a digit.
To ensure alignment, any characters appearing before or after the number in the formatted output such as currency or
sign symbols are padded as necessary with space characters to make their positive and negative formats an equal
length.
Right precision
o . p - A period followed by the number of digits ( p) after the decimal character. If the value of p is 0 (zero),
the decimal character and the digits to its right will be omitted. If no right precision is included, the default
will dictated by the current local in use. The amount being formatted is rounded to the specified number of digits
prior to formatting.
Conversion characters
o i - The number is formatted according to the locale's international currency format (e.g. for the USA locale: USD
1,234.56).
o n - The number is formatted according to the locale's national currency format (e.g. for the de_DE locale:
EU1.234,56).
o % - Returns the % character.
o $number
- The number to be formatted.
RETURN VALUES
Returns the formatted string. Characters before and after the formatting string will be returned unchanged. Non-numeric $number causes
returning NULL and emitting E_WARNING.
NOTES
Note
The function money_format(3) is only defined if the system has strfmon capabilities. For example, Windows does not, so money_for-
mat(3) is undefined in Windows.
Note
The LC_MONETARY category of the locale settings, affects the behavior of this function. Use setlocale(3) to set to the appropriate
default locale before using this function.
EXAMPLES
Example #1
money_format(3) Example
We will use different locales and format specifications to illustrate the use of this function.
<?php
$number = 1234.56;
// let's print the international format for the en_US locale
setlocale(LC_MONETARY, 'en_US');
echo money_format('%i', $number) . "
";
// USD 1,234.56
// Italian national format with 2 decimals`
setlocale(LC_MONETARY, 'it_IT');
echo money_format('%.2n', $number) . "
";
// Eu 1.234,56
// Using a negative number
$number = -1234.5672;
// US national format, using () for negative numbers
// and 10 digits for left precision
setlocale(LC_MONETARY, 'en_US');
echo money_format('%(#10n', $number) . "
";
// ($ 1,234.57)
// Similar format as above, adding the use of 2 digits of right
// precision and '*' as a fill character
echo money_format('%=*(#10.2n', $number) . "
";
// ($********1,234.57)
// Let's justify to the left, with 14 positions of width, 8 digits of
// left precision, 2 of right precision, withouth grouping character
// and using the international format for the de_DE locale.
setlocale(LC_MONETARY, 'de_DE');
echo money_format('%=*^-14#8.2i', 1234.56) . "
";
// Eu 1234,56****
// Let's add some blurb before and after the conversion specification
setlocale(LC_MONETARY, 'en_GB');
$fmt = 'The final value is %i (after a 10%% discount)';
echo money_format($fmt, 1234.56) . "
";
// The final value is GBP 1,234.56 (after a 10% discount)
?>
SEE ALSO setlocale(3), sscanf(3), sprintf(3), printf(3), number_format(3).
PHP Documentation Group MONEY_FORMAT(3)