What does `LOGFILE=$1:-/var/log/syslog` do?How to use syslog for else output ( show up with whois - query )?What does set -e do?What does this “printf” command do?“file /var/log/syslog is being edited” message in nanoscript does not write to file when executed from cronCron job log reads 'No MTA installed', does that prevent the CRON job from finishing?Direct all output to logfileWhat does “$@” do in a bash script?What does “exec 1>/var/opt/log/my_logs/MYPROG_`date '+%Y%m%d_%H%M%S'`.log 2>&1” do?Resume script does nothing

size of pointers and architecture

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

Is it OK to look at the list of played moves during the game to determine the status of the 50 move rule?

If a character has cast the Fly spell on themselves, can they "hand off" to the Levitate spell without interruption?

Proto-Indo-European (PIE) words with IPA

why "American-born", not "America-born"?

Make the `diff` command look only for differences from a specified range of lines

If change in free energy (G) is positive, how do those reactions still occur?

Are there historical examples of audiences drawn to a work that was "so bad it's good"?

Ratings matrix plot

Why is this integration method not valid?

Is it normal to "extract a paper" from a master thesis?

What is the true cause of time dilation? Velocity, momentum or energy?

"Official wife" or "Formal wife"?

mmap: effect of other processes writing to a file previously mapped read-only

A nasty indefinite integral

How to become an Editorial board member?

Three knights or knaves, three different hair colors

What is the required burn to keep a satellite at a Lagrangian point?

Way of refund if scammed?

Are there any tips to help hummingbirds find a new feeder?

How do I write real-world stories separate from my country of origin?

Why is this python script running in background consuming 100 % CPU?

Illustrating that universal optimality is stronger than sphere packing



What does `LOGFILE=$1:-/var/log/syslog` do?


How to use syslog for else output ( show up with whois - query )?What does set -e do?What does this “printf” command do?“file /var/log/syslog is being edited” message in nanoscript does not write to file when executed from cronCron job log reads 'No MTA installed', does that prevent the CRON job from finishing?Direct all output to logfileWhat does “$@” do in a bash script?What does “exec 1>/var/opt/log/my_logs/MYPROG_`date '+%Y%m%d_%H%M%S'`.log 2>&1” do?Resume script does nothing






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















I stumbled across this script containing:



LOGFILE=$1:-/var/log/syslog


What does this line do?










share|improve this question






















  • Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

    – dessert
    7 hours ago

















3















I stumbled across this script containing:



LOGFILE=$1:-/var/log/syslog


What does this line do?










share|improve this question






















  • Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

    – dessert
    7 hours ago













3












3








3








I stumbled across this script containing:



LOGFILE=$1:-/var/log/syslog


What does this line do?










share|improve this question














I stumbled across this script containing:



LOGFILE=$1:-/var/log/syslog


What does this line do?







command-line bash






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 7 hours ago









WinEunuuchs2UnixWinEunuuchs2Unix

50.5k12100195




50.5k12100195












  • Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

    – dessert
    7 hours ago

















  • Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

    – dessert
    7 hours ago
















Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

– dessert
7 hours ago





Close enough IMO, heemayl’s answer explains thoroughly what the pattern with and without : does. If you don’t think the explanation suffices, maybe edit the answer over there? With 13 UVs on the question and 19 on the answer I think it’s save to say that this is our generic post for this particular parameter expansion, and we don’t really need to split things up even more – one post covering parameter expansion in general would be nice.

– dessert
7 hours ago










1 Answer
1






active

oldest

votes


















3














The command: LOGFILE=$1:-/var/log/syslog is shorthand for:



if [[ "$1" == "" ]] # if parameter 1 is blank
then
LOGFILE="/var/log/syslog" # LOGFILE set to /var/log/syslog
else
LOGFILE="$1" # LOGFILE set to parameter 1
fi


If parameter 1 is not passed you see:



yad-logfile 1.png



If you pass paraemeter 1:



journalctl -b > /tmp/messages
yad-logfile /tmp/messages


you see:



yad-logfile 2.png




The original code in question link was modified:



#!/bin/bash

# NAME: yad-logfile
# DATE: May 19, 2019.

# From: https://sourceforge.net/p/yad-dialog/wiki/LogViewer/

# This script demonstrates new features of list dialog. Script displays content
# of specified log file and mark some special strings: with word "kernel" by
# setting italic font, with word "error" by light yellow background and with
# word "warn" by pink background

LOGFILE=$1:-/var/log/syslog

PARSER='font=""; color="#FFFFFF";
/CRON/ font="italic";
/smartd/ color="#FFF4B8";
/upower/ color="#FFD0D8";
OFS="n" print $1 " " $2, $3, $4, substr($5,0,index($5,":")-1),
substr($0,index($0,$6)), font, color; fflush()'

cat $LOGFILE | awk "$PARSER" |
yad --title="Log viewer" --window-icon=logviewer
--button=gtk-close --geometry 600x350
--list --text="Content of $LOGFILE"
--column Date --column Time --column Host
--column Tag --column Message:TIP
--column @font@ --column @back@

exit $?





share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144591%2fwhat-does-logfile-1-var-log-syslog-do%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    The command: LOGFILE=$1:-/var/log/syslog is shorthand for:



    if [[ "$1" == "" ]] # if parameter 1 is blank
    then
    LOGFILE="/var/log/syslog" # LOGFILE set to /var/log/syslog
    else
    LOGFILE="$1" # LOGFILE set to parameter 1
    fi


    If parameter 1 is not passed you see:



    yad-logfile 1.png



    If you pass paraemeter 1:



    journalctl -b > /tmp/messages
    yad-logfile /tmp/messages


    you see:



    yad-logfile 2.png




    The original code in question link was modified:



    #!/bin/bash

    # NAME: yad-logfile
    # DATE: May 19, 2019.

    # From: https://sourceforge.net/p/yad-dialog/wiki/LogViewer/

    # This script demonstrates new features of list dialog. Script displays content
    # of specified log file and mark some special strings: with word "kernel" by
    # setting italic font, with word "error" by light yellow background and with
    # word "warn" by pink background

    LOGFILE=$1:-/var/log/syslog

    PARSER='font=""; color="#FFFFFF";
    /CRON/ font="italic";
    /smartd/ color="#FFF4B8";
    /upower/ color="#FFD0D8";
    OFS="n" print $1 " " $2, $3, $4, substr($5,0,index($5,":")-1),
    substr($0,index($0,$6)), font, color; fflush()'

    cat $LOGFILE | awk "$PARSER" |
    yad --title="Log viewer" --window-icon=logviewer
    --button=gtk-close --geometry 600x350
    --list --text="Content of $LOGFILE"
    --column Date --column Time --column Host
    --column Tag --column Message:TIP
    --column @font@ --column @back@

    exit $?





    share|improve this answer



























      3














      The command: LOGFILE=$1:-/var/log/syslog is shorthand for:



      if [[ "$1" == "" ]] # if parameter 1 is blank
      then
      LOGFILE="/var/log/syslog" # LOGFILE set to /var/log/syslog
      else
      LOGFILE="$1" # LOGFILE set to parameter 1
      fi


      If parameter 1 is not passed you see:



      yad-logfile 1.png



      If you pass paraemeter 1:



      journalctl -b > /tmp/messages
      yad-logfile /tmp/messages


      you see:



      yad-logfile 2.png




      The original code in question link was modified:



      #!/bin/bash

      # NAME: yad-logfile
      # DATE: May 19, 2019.

      # From: https://sourceforge.net/p/yad-dialog/wiki/LogViewer/

      # This script demonstrates new features of list dialog. Script displays content
      # of specified log file and mark some special strings: with word "kernel" by
      # setting italic font, with word "error" by light yellow background and with
      # word "warn" by pink background

      LOGFILE=$1:-/var/log/syslog

      PARSER='font=""; color="#FFFFFF";
      /CRON/ font="italic";
      /smartd/ color="#FFF4B8";
      /upower/ color="#FFD0D8";
      OFS="n" print $1 " " $2, $3, $4, substr($5,0,index($5,":")-1),
      substr($0,index($0,$6)), font, color; fflush()'

      cat $LOGFILE | awk "$PARSER" |
      yad --title="Log viewer" --window-icon=logviewer
      --button=gtk-close --geometry 600x350
      --list --text="Content of $LOGFILE"
      --column Date --column Time --column Host
      --column Tag --column Message:TIP
      --column @font@ --column @back@

      exit $?





      share|improve this answer

























        3












        3








        3







        The command: LOGFILE=$1:-/var/log/syslog is shorthand for:



        if [[ "$1" == "" ]] # if parameter 1 is blank
        then
        LOGFILE="/var/log/syslog" # LOGFILE set to /var/log/syslog
        else
        LOGFILE="$1" # LOGFILE set to parameter 1
        fi


        If parameter 1 is not passed you see:



        yad-logfile 1.png



        If you pass paraemeter 1:



        journalctl -b > /tmp/messages
        yad-logfile /tmp/messages


        you see:



        yad-logfile 2.png




        The original code in question link was modified:



        #!/bin/bash

        # NAME: yad-logfile
        # DATE: May 19, 2019.

        # From: https://sourceforge.net/p/yad-dialog/wiki/LogViewer/

        # This script demonstrates new features of list dialog. Script displays content
        # of specified log file and mark some special strings: with word "kernel" by
        # setting italic font, with word "error" by light yellow background and with
        # word "warn" by pink background

        LOGFILE=$1:-/var/log/syslog

        PARSER='font=""; color="#FFFFFF";
        /CRON/ font="italic";
        /smartd/ color="#FFF4B8";
        /upower/ color="#FFD0D8";
        OFS="n" print $1 " " $2, $3, $4, substr($5,0,index($5,":")-1),
        substr($0,index($0,$6)), font, color; fflush()'

        cat $LOGFILE | awk "$PARSER" |
        yad --title="Log viewer" --window-icon=logviewer
        --button=gtk-close --geometry 600x350
        --list --text="Content of $LOGFILE"
        --column Date --column Time --column Host
        --column Tag --column Message:TIP
        --column @font@ --column @back@

        exit $?





        share|improve this answer













        The command: LOGFILE=$1:-/var/log/syslog is shorthand for:



        if [[ "$1" == "" ]] # if parameter 1 is blank
        then
        LOGFILE="/var/log/syslog" # LOGFILE set to /var/log/syslog
        else
        LOGFILE="$1" # LOGFILE set to parameter 1
        fi


        If parameter 1 is not passed you see:



        yad-logfile 1.png



        If you pass paraemeter 1:



        journalctl -b > /tmp/messages
        yad-logfile /tmp/messages


        you see:



        yad-logfile 2.png




        The original code in question link was modified:



        #!/bin/bash

        # NAME: yad-logfile
        # DATE: May 19, 2019.

        # From: https://sourceforge.net/p/yad-dialog/wiki/LogViewer/

        # This script demonstrates new features of list dialog. Script displays content
        # of specified log file and mark some special strings: with word "kernel" by
        # setting italic font, with word "error" by light yellow background and with
        # word "warn" by pink background

        LOGFILE=$1:-/var/log/syslog

        PARSER='font=""; color="#FFFFFF";
        /CRON/ font="italic";
        /smartd/ color="#FFF4B8";
        /upower/ color="#FFD0D8";
        OFS="n" print $1 " " $2, $3, $4, substr($5,0,index($5,":")-1),
        substr($0,index($0,$6)), font, color; fflush()'

        cat $LOGFILE | awk "$PARSER" |
        yad --title="Log viewer" --window-icon=logviewer
        --button=gtk-close --geometry 600x350
        --list --text="Content of $LOGFILE"
        --column Date --column Time --column Host
        --column Tag --column Message:TIP
        --column @font@ --column @back@

        exit $?






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        WinEunuuchs2UnixWinEunuuchs2Unix

        50.5k12100195




        50.5k12100195



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144591%2fwhat-does-logfile-1-var-log-syslog-do%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її