{"id":845,"date":"2018-02-07T15:19:07","date_gmt":"2018-02-08T00:19:07","guid":{"rendered":"\/blog\/?p=845"},"modified":"2023-09-21T09:37:37","modified_gmt":"2023-09-21T00:37:37","slug":"shell-script-if%eb%ac%b8","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=845","title":{"rendered":"shell script if\ubb38"},"content":{"rendered":"\n<div style=\"\"><span style=\"font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;; font-size: 12px;\">\u25a0 \ubb38\uc790\uc5f4 \ube44\uad50<\/span><br \/><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ string ] - string\uc774 \ube48 \ubb38\uc790\uc5f4\uc774 \uc544\ub2c8\ub77c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ string1 = string2 ] - \ub450 \ubb38\uc790\uc5f4\uc774 \uac19\ub2e4\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ string1 != string2 ] - \ub450 \ubb38\uc790\uc5f4\uc774 \ub2e4\ub974\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -n string ] - \ubb38\uc790\uc5f4\uc774 null(\ube48 \ubb38\uc790\uc5f4) \uc774 \uc544\ub2c8\ub77c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -z string ] - \ubb38\uc790\uc5f4\uc774 null(\ube48 \ubb38\uc790\uc5f4) \uc774\ub77c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">\u25a0 \uc0b0\uc220 \ube44\uad50<\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -eq expr2 ] - \ub450 \ud45c\ud604\uc2dd \uac12\uc774 \uac19\ub2e4\uba74 \ucc38 ('EQual')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -ne expr2 ] - \ub450 \ud45c\ud604\uc2dd \uac12\uc774 \uac19\uc9c0 \uc54a\ub2e4\uba74 \ucc38 ('Not Equal')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -gt expr2 ] - expr1 &gt; expr2 \uc774\uba74 \ucc38 ('Greater Than')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -ge expr2 ] - expr1 &gt;= expr2 \uc774\uba74 \ucc38 ('Greater Equal')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -lt expr2 ] - expr1 &lt; expr2 \uc774\uba74 \ucc38 ('Less Than')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -le expr2 ] - expr1 &lt;= expr2 \uc774\uba74 \ucc38 ('Less Equal')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ ! expr ] - expr \uc774 \ucc38\uc774\uba74 \uac70\uc9d3, \uac70\uc9d3\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -a expr2 ] - expr1 AND expr2 \uc758 \uacb0\uacfc (\ub458\ub2e4 \ucc38\uc774\uba74 \ucc38, 'And')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ expr1 -o expr2 ] - expr1 OR expr2 \uc758 \uacb0\uacfc (\ub458\uc911 \ud558\ub098\ub9cc \ucc38\uc774\uba74 \ucc38, 'Or')<\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">\u25a0 \ud30c\uc77c \uc870\uac74<\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -b FILE ] - FILE \uc774 \ube14\ub7ed \ub514\ubc14\uc774\uc2a4 \uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -c FILE ] - FILE \uc774 \ubb38\uc790 \ub514\ubc14\uc774\uc2a4 \uc774\uba74 \ucc38.<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -d FILE ] - FILE \uc774 \ub514\ub809\ud1a0\ub9ac\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -e FILE ] - FILE \uc774 \uc874\uc7ac\ud558\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -f FILE ] - FILE \uc774 \uc874\uc7ac\ud558\uace0 \uc815\uaddc\ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -g FILE ] - FILE \uc774 set-group-id \ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -h FILE ] - FILE \uc774 \uc2ec\ubcfc\ub9ad \ub9c1\ud06c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -L FILE ] - FILE \uc774 \uc2ec\ubcfc\ub9ad \ub9c1\ud06c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -k FILE ] - FILE \uc774 Sticky bit \uac00 \uc14b\ud305\ub418\uc5b4 \uc788\uc73c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -p FILE ] - True if file is a named pipe.<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -r FILE ] - \ud604\uc7ac \uc0ac\uc6a9\uc790\uac00 \uc77d\uc744 \uc218 \uc788\ub294 \ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -s FILE ] - \ud30c\uc77c\uc774 \ube44\uc5b4\uc788\uc9c0 \uc54a\uc73c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -S FILE ] - \uc18c\ucf13 \ub514\ubc14\uc774\uc2a4\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -t FD ] - FD \uac00 \uc5f4\ub824\uc9c4 \ud130\ubbf8\ub110\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -u FILE ] - FILE \uc774 set-user-id \ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -w FILE ] - \ud604\uc7ac \uc0ac\uc6a9\uc790\uac00 \uc4f8 \uc218 \uc788\ub294 \ud30c\uc77c(writable file) \uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -x FILE ] - \ud604\uc7ac\uc0ac\uc6a9\uc790\uac00 \uc2e4\ud589\ud560 \uc218 \uc788\ub294 \ud30c\uc77c(Executable file) \uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -O FILE ] - FILE \uc758 \uc18c\uc720\uc790\uac00 \ud604\uc7ac \uc0ac\uc6a9\uc790\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ -G FILE ] - FILE \uc758 \uadf8\ub8f9\uc774 \ud604\uc7ac \uc0ac\uc6a9\uc790\uc758 \uadf8\ub8f9\uacfc \uac19\uc73c\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ FILE1 -nt FILE2 ] - : FILE1\uc774 FILE2 \ubcf4\ub2e4 \uc0c8\ub85c\uc6b4 \ud30c\uc77c\uc774\uba74 ( \ucd5c\uadfc\ud30c\uc77c\uc774\uba74 ) \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ FILE1 -ot FILE2 ] - : FILE1\uc774 FILE2 \ubcf4\ub2e4 \uc624\ub798\ub41c \ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">[ FILE1 -ef FILE2 ] - : FILE1 \uc774 FILE2\uc758 \ud558\ub4dc\ub9c1\ud06c \ud30c\uc77c\uc774\uba74 \ucc38<\/span><\/div><div style=\"\"><span style=\"font-size: 12px;\"><br \/><\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">#####################################################################<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">#<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\"># rsync \ucc3e\uae30 \uc608\uc81c<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">#<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\">#####################################################################<\/span><\/div><div style=\"\"><span style=\"font-size: 12px; font-family: GulimChe, &quot;Courier New&quot;, &quot;Lucida Console&quot;;\"><div>if [ -x \/bin\/rsync ]; then<\/div><div>&nbsp; RSYNC_CMD=\/bin\/rsync<\/div><div>elif [ -x \/usr\/bin\/rsync ]; then<\/div><div>&nbsp; RSYNC_CMD=\/usr\/bin\/rsync<\/div><div>elif [ -x \/usr\/local\/bin\/rsync ]; then<\/div><div>&nbsp; RSYNC_CMD=\/usr\/local\/bin\/rsync<\/div><div>else<\/div><div>&nbsp; echo \"rsync not found.\"<\/div><div>&nbsp; exit 1<\/div><div>fi<\/div><div>echo $RSYNC_CMD<\/div><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u25a0 \ubb38\uc790\uc5f4 \ube44\uad50 [ string ] &#8211; string\uc774 \ube48 \ubb38\uc790\uc5f4\uc774 \uc544\ub2c8\ub77c\uba74 \ucc38 [ string1 = string2 ] &#8211; \ub450 \ubb38\uc790\uc5f4\uc774 \uac19\ub2e4\uba74 \ucc38 [ string1 != string2 ] &#8211; \ub450 \ubb38\uc790\uc5f4\uc774 \ub2e4\ub974\uba74 \ucc38 [ -n string ] &#8211; \ubb38\uc790\uc5f4\uc774 null(\ube48 \ubb38\uc790\uc5f4) \uc774 \uc544\ub2c8\ub77c\uba74 \ucc38 [ -z string ] &#8211; \ubb38\uc790\uc5f4\uc774 null(\ube48 \ubb38\uc790\uc5f4) \uc774\ub77c\uba74 \ucc38 \u25a0 \uc0b0\uc220 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[22],"tags":[],"class_list":["post-845","post","type-post","status-publish","format-standard","hentry","category-development_unix"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/845","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=845"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/845\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=845"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=845"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=845"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}