- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: date format with a file
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
11-22-2005 08:44 PM
11-22-2005 08:44 PM
date format with a file
I wanted to add date format along with a file, can anyone help...
for e.g
date +%Y%m%d which gives 20051123, this should be attached to a file to say like "test.20051123".......
Thank you in advance.
Regards,
Robs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 08:51 PM
11-22-2005 08:51 PM
Re: date format with a file
tocuch test.$(date +%Y%m%d)
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 08:52 PM
11-22-2005 08:52 PM
Re: date format with a file
Try this
dateA=`date +%Y%m%d`
cat abc > test.$dateA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 08:53 PM
11-22-2005 08:53 PM
Re: date format with a file
touch test.$(date +%Y%m%d)
or as,
cat > test.`date +%Y%m%d`
hi
ctr+d
or
cp /dev/null test.`date +%Y%m%d`
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 08:57 PM
11-22-2005 08:57 PM
Re: date format with a file
A note for you.
If we are using the code of,
dateA=`date +%Y%m%d`
cat abc > test.$dateA
with shell script then,
dateA will be with 20051123.
test.($2)0051123
if we give argument with more than one then, second argument is substitued (say example ./script.ksh first luk third)
then,
file will be like,
test.luk0051123
to over ride that,
dateA=`date +%Y%m%d`
cat abc > test.${dateA}
that is all.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:12 PM
11-22-2005 09:12 PM
Re: date format with a file
The thing is it works if it is a simple file creation....
I would like to append to the file with each output that arrives through my commands,
for e.g,
the commands i try might bdf, swapinfo and so on....
these outputs needs to be appended along with the file "test.20051123"
The normal way of the using the date command doesnt seem to accept the redirections....
i tried using the following,
dateA='date +%Y%m%d'
touch log.$dateA
bdf >> log.$dateA
can u help........
Thank you.
Regards,
Robs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:23 PM
11-22-2005 09:23 PM
Re: date format with a file
Have u used 'date +%Y%m%d' or `date +%Y%m%d`
There is difference in the quotes being used.
IF you want the variable dateA to be available in that shell, do
export dateA=`date +%Y%m%d`
touch log.$dateA
bdf>>log.$dateA
It works for me...!!!!
Regrds
CS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:28 PM
11-22-2005 09:28 PM
Re: date format with a file
Use like,
FILE="log.$(date +%Y%m%d)"
bdf >> ${FILE}
swapinfo -tam >> ${FILE}
else
FILE="log.$(date +%Y%m%d)"
(
bdf
swapinfo -tam
hostname
ls
) > ${FILE}
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:41 PM
11-22-2005 09:41 PM
Re: date format with a file
{
command1
command2
...
commandn
} > test.$(date +%Y%m%d)
To get that result in console also then,
{
command1
command2
...
commandn
} | tee -a test.$(date +%Y%m%d)
tee with -a will append results more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:42 PM
11-22-2005 09:42 PM
Re: date format with a file
Regards,
Robs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2005 09:43 PM
11-22-2005 09:43 PM