Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 19 of 19
Like Tree1Likes
If you want output like this: Today's date is Mon Oct 24 06:59:32 EDT 2011, this is week 43. Your script should be: #!/bin/bash echo "Today's date is `date`, this ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2007
    Location
    Tucson AZ
    Posts
    3,190

    If you want output like this:

    Today's date is Mon Oct 24 06:59:32 EDT 2011, this is week 43.
    Your script should be:

    #!/bin/bash
    echo "Today's date is `date`, this is week `date +"%V"`."
    After creating the script and saving it as mysystem.sh, go to the directory in which you saved it and give it executable permissions:

    chmod 755 mysystem.sh
    Your script contents are different than your original post. I'm not really sure what you are trying to get for output?

  2. #12
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11
    The problem is
    when i type
    Code:
    echo " this is the ,' date' "
    the command date does not show result of running this command
    it shows
    Code:
    this is the 'date'
    see the script that i posted
    also see the output
    and you will understand
    please take into considration that i am beginner
    regardes

  3. #13
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    because you are not using ticks (`). Use ticks not single quotes. A tick tells a script to execute a command in a separate shell outside of the script.

    so instead of:
    Code:
    echo " this is the ,' date' "
    use
    Code:
    echo " this is the ,`date` "
    linux user # 503963

  4. #14
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,288
    Hi.

    Quoting can be confusing. See Quoting characters for some general help, and I suggest you bookmark the entire URL.

    I have found that
    Code:
    $(command)
    is preferable to
    Code:
    `command`
    for a number of reasons ... cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  5. #15
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11
    Thanks guys
    Thank you Drl
    but i cant found the tickes in the keyboard
    Is there any configuration you can post for me.....Am using CentOS....I'a on hurry
    I really appreciat
    thanks again !!

  6. #16
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    if you can't find it, just do what drl said:
    Code:
    echo $(date +%m)
    11
    linux user # 503963

  7. #17
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11
    Quote Originally Posted by scathefire View Post
    because you are not using ticks (`). Use ticks not single quotes. A tick tells a script to execute a command in a separate shell outside of the script.

    so instead of:
    Code:
    echo " this is the ,' date' "
    use
    Code:
    echo " this is the ,`date` "
    Yes I know
    but i cant find tickes.....how to make it work

  8. #18
    Just Joined!
    Join Date
    Oct 2011
    Posts
    11
    Thanks Drl thnks every one
    it works useing
    $(date)

    but if some one can tell how make tickes work would be better

  9. #19
    Linux Enthusiast scathefire's Avatar
    Join Date
    Jan 2010
    Location
    Western Kentucky
    Posts
    626
    on a standard US keyboard, its right next to the number 1 key, below the escape key
    Abdelellah likes this.
    linux user # 503963

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •