Re: quick script question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

M E Fieu wrote:
> Hi.. Need to ask you a simple script question,  I used the date
> command to get the yesterday web log file using the following
> command echo ex`date -d yesterday +%y%m%d.log`  in Linux.  I want to
> create a simple script to cat /home/IT/ex060530.log> kr.log using
> the following script but it is not working.  May I know how do I put
> the output of echo ex`date -d yesterday +%y%m%d.log into cat
> /home/IT/xxxx> kr.log ?
> 
> [root@w2 krweblog3]# echo ex`date -d yesterday +%y%m%d.log`
> ex060530.log
>
> [root@w2 krweblog3]# vi krweblog.sh
> 
> #!/bin/sh
> #
> KRWEBLOG3= echo ex`date -d yesterday +%y%m%d.log`
> cat /home/IT/$KRWEBLOG3> kr.log

Get rid of the echo, it's not needed.

KRWEBLOG3="ex`date -d yesterday +%y%m%d.log`

If you ever do have to run a few commands to create a variable, you
can use bash's command substitution to nest commands.  Instead of
using backquotes (`command`), you use $(command).

KRWEBLOG3=$(echo ex$(date -d yesterday +%y%m%d.log))

See the section on Expansion in the bash man page for more details.

- -- 
Todd        OpenPGP -> KeyID: 0xD654075A | URL: www.pobox.com/~tmz/pgp
======================================================================
A free society is one where it is safe to be unpopular.
    -- Adlai Stevenson

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: When crypto is outlawed bayl bhgynjf jvyy unir cevinpl.

iG0EARECAC0FAkR9KCImGGh0dHA6Ly93d3cucG9ib3guY29tL350bXovcGdwL3Rt
ei5hc2MACgkQuv+09NZUB1ql+ACg33aPbJCie1mqHi5QXcCAVck5iLkAoM6ovyWO
f7lLilm/oUK89/qpt4hg
=etmy
-----END PGP SIGNATURE-----

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux