{"id":908,"date":"2024-10-29T12:36:10","date_gmt":"2024-10-29T12:36:10","guid":{"rendered":"https:\/\/vickistan.com\/?p=908"},"modified":"2025-10-31T15:03:51","modified_gmt":"2025-10-31T15:03:51","slug":"cool-bash-commands","status":"publish","type":"post","link":"https:\/\/vickistan.com\/?p=908","title":{"rendered":"Cool Bash Commands"},"content":{"rendered":"\n<p>Remove the ABCD&#8211; prefix from a filename:<br \/><code>$ s='ABCD--11212239.pdf'<br \/>$ mv \"$s\" \"${s#ABCD--}\"<\/code><br \/><br \/>Remove the prefix from all files in current directory recursively:<br \/><code>while IFS= read -r -d '' filename; do<br \/>  mv \"$filename\" \"${filename#ABCD--}\"<br \/>done &lt; &lt;(find . -type f -name 'ABCD--*' -print0)<\/code><\/p>\n\n\n\n<p>Remove the .pdf suffix from a filename:<br \/><code>$ s='ABCD--11212239.pdf'<br \/>$ mv \"$s\" \"${s%.pdf}\"<\/code><br \/><br \/>Remove the &#8220;r_&#8221; prefix from all the files in the current directory:<br \/><code>for each in ls r_*; do mv $filename ${filename#r_}; done<\/code><br \/><br \/>Remove the &#8220;pdf&#8221; suffix from all the files in the current directory recursively:<br \/><code>while IFS= read -r -d '' filename; do<br \/>  mv \"$filename\" \"${filename%.pdf}\"<br \/>done &lt; &lt;(find . -type f -name '*.pdf' -print0)<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Remove the ABCD&#8211; prefix from a filename:$ s=&#8217;ABCD&#8211;11212239.pdf&#8217;$ mv &#8220;$s&#8221; &#8220;${s#ABCD&#8211;}&#8221; Remove the prefix from all files in current directory recursively:while IFS= read -r -d &#8221; filename; do mv &#8220;$filename&#8221; &#8220;${filename#ABCD&#8211;}&#8221;done &lt; &lt;(find . -type f -name &#8216;ABCD&#8211;*&#8217; -print0) Remove &hellip; <a href=\"https:\/\/vickistan.com\/?p=908\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-908","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/908","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=908"}],"version-history":[{"count":5,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions"}],"predecessor-version":[{"id":976,"href":"https:\/\/vickistan.com\/index.php?rest_route=\/wp\/v2\/posts\/908\/revisions\/976"}],"wp:attachment":[{"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=908"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=908"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vickistan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=908"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}