{"id":538,"date":"2014-02-05T08:22:44","date_gmt":"2014-02-05T16:22:44","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=538"},"modified":"2014-02-05T08:22:44","modified_gmt":"2014-02-05T16:22:44","slug":"bash-and-exclusions-in-a-list","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/bash-and-exclusions-in-a-list\/","title":{"rendered":"Bash And Exclusions in a List"},"content":{"rendered":"

Just a quick snippet on doing exclusions when you loop through a list.<\/p>\n

\r\nDIRS=`ls -l --time-style="long-iso" $MYDIR | egrep '^d' | awk '{print $8}'`\r\nEXCLUDELIST="mail Mail"\r\n\r\nfor EXCLUDE in $EXCLUDELIST\r\ndo\r\n    DIRS=`echo $DIRS | sed "s\/\\b$EXCLUDE\\b\/\/g"`\r\ndone\r\n\r\nfor DIR in $DIRS\r\ndo\r\n    echo  ${DIR} :\r\ndone\r\n<\/pre>\n

For some reason on Solaris sed had an issue with \"\\b\" so I adjusted to sed \"s\/$EXCLUDE\/\/g\". Shown as follow:<\/p>\n

\r\n#Linux:\r\n$ echo "d1 d2 d3" | sed "s\/\\bd2\\b\/\/g"\r\nd1  d3\r\n\r\n# Solaris Fails:\r\n# echo "d1 d2 d3" | sed "s\/\\bd2\\b\/\/g"\r\nd1 d2 d3\r\n\r\n# Solaris Works\r\n# echo "d1 d2 d3" | sed "s\/d2\/\/g"\r\nd1  d3\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Just a quick snippet on doing exclusions when you loop through a list. DIRS=`ls -l –time-style="long-iso" $MYDIR | egrep ‘^d’<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-538","post","type-post","status-publish","format-standard","hentry","category-bash"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/538","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=538"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/538\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=538"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=538"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=538"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}