- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Adding spaces among two or more variables ....
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 09:41 AM
05-02-2008 09:41 AM
this is the code in question:
a=`perl -MPOSIX -le 'print strftime "%b %d",localtime(time-86400)'`
echo valor de a $a
case `echo $a | cut -d" " -f2 | cut -c1 | sed 's/ //g'` in
"0" ) echo estoy adentro del case; mm=`echo $a | cut -d" " -f1`
dd=`echo $a | cut -d" " -f2 | cut -c2`; esp=" " ; b="$mm$esp$dd" ;;
esac
$ ./printers_in_use.sh
value of a: May 01
estoy adentro del case
esto vale ahora b: May 1
how can i do?
i need b appears as follows: May 1 (with two spaces between May and 1)
please let me kow.
thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 09:54 AM
05-02-2008 09:54 AM
Solution> need b appears as follows: May 1 (with two spaces between May and 1)
You use this:
# perl -MPOSIX -le 'print strftime "%b %e",localtime(time-86400)'
That is, change the "%d" to a "%e" just as the manpages for 'date' would show you.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 11:24 AM
05-02-2008 11:24 AM
Re: Adding spaces among two or more variables ....
but i need "two spaces" not one ...
$ a=`perl -MPOSIX -le 'print strftime "%b %e",localtime(time-86400)'`
$ echo $a
May 1
$
how can i do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 11:26 AM
05-02-2008 11:26 AM
Re: Adding spaces among two or more variables ....
this is the correct script:
a=`perl -MPOSIX -le 'print strftime "%b %e",localtime(time-86400)'`
echo valor de a $a
case `echo $a | cut -d" " -f2 | cut -c1 | sed 's/ //g'` in
"0" ) echo estoy adentro del case; mm=`echo $a | cut -d" " -f1`
dd=`echo $a | cut -d" " -f2 | cut -c2`; esp=" " ; b="$mm$esp$dd" ;;
esac
$ a=`perl -MPOSIX -le 'print strftime "%b %e",localtime(time-86400)'`
$ echo $a
May 1
i need two spaces instead of one in "May 1"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 11:37 AM
05-02-2008 11:37 AM
Re: Adding spaces among two or more variables ....
> $ a=`perl -MPOSIX -le 'print strftime "%b %e",localtime(time-86400)'`
> $ echo $a
The Perl is now correct, but your 'echo' is NOT. You need to double quote the variable you echo to preserve multiple spaces:
# echo "$a"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2008 12:16 PM
05-02-2008 12:16 PM
Re: Adding spaces among two or more variables ....
$
$ echo "$a"
May 1
YOU ARE CORRECT !!!!!!!!!!!!
THANKS A LOT !!!!!
YOU ARE AMAZING !!!!!!!!!!