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
JavaScript: Access 'this' when calling function stored in variable
How to tease a romance without a cat and mouse chase?
If I arrive in the UK, and then head to mainland Europe, does my Schengen visa 90 day limit start when I arrived in the UK, or mainland Europe?
Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?
How do I write real-world stories separate from my country of origin?
How did the Allies achieve air superiority on Sicily?
Way of refund if scammed?
Is it safe to redirect stdout and stderr to the same file without file descriptor copies?
Which values for voltage divider
csname in newenviroment
Download app bundles from App Store to run on iOS Emulator on Mac
(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?
Shell builtin `printf` line limit?
Keeping the dodos out of the field
Team member is vehemently against code formatting
Is the default 512 byte physical sector size appropriate for SSD disks under Linux?
Meaning of "half-crown enclosure"
Why the work done is positive when bringing 2 opposite charges together?
Can diplomats be allowed on the flight deck of a commercial European airline?
Negative impact of having the launch pad away from the Equator
Illustrating that universal optimality is stronger than sphere packing
How to become an Editorial board member?
Why did Drogon do this?
Why "strap-on" boosters, and how do other people say it?
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;
I stumbled across this script containing:
LOGFILE=$1:-/var/log/syslog
What does this line do?
command-line bash
add a comment |
I stumbled across this script containing:
LOGFILE=$1:-/var/log/syslog
What does this line do?
command-line bash
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
9 hours ago
add a comment |
I stumbled across this script containing:
LOGFILE=$1:-/var/log/syslog
What does this line do?
command-line bash
I stumbled across this script containing:
LOGFILE=$1:-/var/log/syslog
What does this line do?
command-line bash
command-line bash
asked 10 hours ago
WinEunuuchs2UnixWinEunuuchs2Unix
50.6k12100195
50.6k12100195
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
9 hours ago
add a comment |
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
9 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
9 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
9 hours ago
add a comment |
1 Answer
1
active
oldest
votes
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:
If you pass paraemeter 1:
journalctl -b > /tmp/messages
yad-logfile /tmp/messages
you see:
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 $?
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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:
If you pass paraemeter 1:
journalctl -b > /tmp/messages
yad-logfile /tmp/messages
you see:
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 $?
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
add a comment |
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:
If you pass paraemeter 1:
journalctl -b > /tmp/messages
yad-logfile /tmp/messages
you see:
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 $?
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
add a comment |
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:
If you pass paraemeter 1:
journalctl -b > /tmp/messages
yad-logfile /tmp/messages
you see:
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 $?
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:
If you pass paraemeter 1:
journalctl -b > /tmp/messages
yad-logfile /tmp/messages
you see:
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 $?
answered 10 hours ago
WinEunuuchs2UnixWinEunuuchs2Unix
50.6k12100195
50.6k12100195
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
add a comment |
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
IMHO if [[ "$1" == "" ]] is not entirely equivalent. This tries to expand $1, whereas parameter expansion is intended for cases where $1 was not defined or unset. It is far more useful with environment variables like HOME for cases when they may be missing. Setting a variable to empty string in this code would produce similar effect but is not the same no variable in environment.
– Sergiy Kolodyazhnyy
2 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
9 hours ago