- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Something wrong with echo?
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
Discussions
Discussions
Forums
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
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
тАО08-17-2006 05:40 AM
тАО08-17-2006 05:40 AM
Re: Something wrong with echo?
of course I'm sure there are people that will disagree with this solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 05:41 AM
тАО08-17-2006 05:41 AM
Re: Something wrong with echo?
I really don't know Perl and I don't want to convert all of my scripts to Perl right now. Patrick's idea works and Clay's idea of using the zsh worked. I didn't even know there was a z shell. Clay, the temp file worked but shouldn't there be a rm after the file is read?
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 05:48 AM
тАО08-17-2006 05:48 AM
Re: Something wrong with echo?
trap 'eval rm -f ${T1}' 0 1 2 15
This means that if the process receives a SIGHUP (1), a SIGINT (2), or a SIGTERM (15) that the rm command will be executed BUT note the '0' -- that is triggered on a normal exit so that when the process exits (even without a signal) the trap is still executed and the rm is done. I do see that it would also be wise to add a '3' (SIGQUIT) to the list of signals in the trap.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 05:51 AM
тАО08-17-2006 05:51 AM
Re: Something wrong with echo?
I didn't mean to necessarily suggest that a total conversion to Perl was necessary. I meant to point out that it is a portable solution that bears consideration.
Clay's approach automatically removes the temporary file he creates when your script exits. Look at the 'trap' statement.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 05:57 AM
тАО08-17-2006 05:57 AM
Re: Something wrong with echo?
I should add that your *shell* script could always call a perl snippet to do the work needed, no differently then shell scripts call 'awk' or 'sed programs. For instance:
TIMES=`perl -MPOSIX=strftime -le 'print strftime "Year: %Y Month: %m Day: %d Hour: %H Min: %M Sec: %S",localtime(time)'`
echo ${TIMES}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2006 05:59 AM
тАО08-17-2006 05:59 AM
Re: Something wrong with echo?
Thanks to everybody for all the quick answers. I will probably use zsh for now on linux and posix shell on HPUX but I may convert everything to the temp file method.
Thanks,
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 11:27 AM
тАО08-25-2006 11:27 AM
Re: Something wrong with echo?
typeset -i i=0
t=$(date "+%Y %m %d %H %M %S")
for x in $t ; do
ts[i]=$x
i=i+1
done
echo year=${ts[0]}
echo month=${ts[1]}
echo day=${ts[2]}
echo hr=${ts[3]}
echo min=${ts[4]}
echo sec=${ts[5]}
-Eric
- Tags:
- command substitution
- « Previous
-
- 1
- 2
- Next »