{"id":52817,"date":"2026-08-03T16:35:59","date_gmt":"2026-08-03T20:35:59","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=52817"},"modified":"2026-08-03T16:35:59","modified_gmt":"2026-08-03T20:35:59","slug":"pasting-quoted-paths-and-escaped-terminal-text","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2026\/08\/03\/pasting-quoted-paths-and-escaped-terminal-text\/","title":{"rendered":"Pasting Quoted Paths and Escaped Terminal Text"},"content":{"rendered":"<p><a href=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/14\/copy-as-pathname.html\">Anthony Reimer<\/a>:<\/p>\n<blockquote cite=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/14\/copy-as-pathname.html\">\n<p>When you are shell scripting or working in Terminal, sometimes you want a quicker way to enter the path to a file or folder, particularly if you have already navigated to it in the Finder. One way that works in Terminal is to drag the file or folder from the Finder onto the Terminal window, which then types the path into the current command. However, another method was introduced in El Capitan (OS X 10.11) that allows you to copy the full path onto the clipboard.<\/p>\n<\/blockquote>\n<p>In Finder, you can hold down Option and choose <strong>Edit &#x2023; Copy Pathname<\/strong>.<\/p>\n\n<blockquote cite=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/14\/copy-as-pathname.html\">\n<p>Starting in macOS Sequoia, copying the path to the clipboard using the method described generates a path that can be directly pasted into the Terminal or a script and be interpreted as that path without further manipulation.<\/p>\n<\/blockquote>\n\n<p>It adds single quotes and or escapes characters, but only if necessary.<\/p>\n\n<blockquote cite=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/14\/copy-as-pathname.html\">\n<p>There are certainly some people who are <a href=\"https:\/\/discussions.apple.com\/thread\/255762727?sortBy=rank\">unhappy with this change in behaviour<\/a> but most Mac Admins will not be among them.<\/p>\n<\/blockquote>\n<p>You can get the unescaped path <a href=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/20\/paste-escaped-text.html\">via AppleScript<\/a>.<\/p>\n\n<p><a href=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/20\/paste-escaped-text.html\">Anthony Reimer<\/a> (via <a href=\"https:\/\/tinyapps.org\/blog\/copied-pathname-quotes.html\">Miles Wolbe<\/a>):<\/p>\n<blockquote cite=\"https:\/\/maclabs.jazzace.ca\/2024\/12\/20\/paste-escaped-text.html\">\n<p><a href=\"https:\/\/macadmins.slack.com\/archives\/C4ENKD38A\/p1734333526868049\">Graham Pugh pointed out<\/a> that if you have text on the clipboard, you have the option of pasting that text &ldquo;escaped&rdquo; in Terminal. Simply copy the text from whatever source you choose (e.g., the output of an AutoPkg run, where paths are not escaped), then in Terminal choose Edit &gt; Pasted Escaped Text or use the shortcut Command-Control-V.<\/p>\n<p>[&#8230;]<\/p>\n<p>As a bonus, this concept can be applied to <a href=\"https:\/\/scriptingosx.com\/obscure\/\">a tip I learned from Armin Briegel a few years ago<\/a>, namely that if you select something in Terminal that you want to then paste into the current shell command, you can skip the copy-paste dance and instead just press Command-Shift-V to do it in one step (or if you prefer menus, Edit &gt; Paste Selection). If you add the Control key to that sequence, the text pasted is escaped (Edit &gt; Paste Escaped Selection or Command-Control-Shift-V).<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Anthony Reimer: When you are shell scripting or working in Terminal, sometimes you want a quicker way to enter the path to a file or folder, particularly if you have already navigated to it in the Finder. One way that works in Terminal is to drag the file or folder from the Finder onto the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2026-08-03T20:36:03Z","apple_news_api_id":"75310b1a-491d-4476-839a-4d0b100799cf","apple_news_api_modified_at":"2026-08-03T20:36:03Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AdTELGkkdRHaDmk0LEAeZzw","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[2],"tags":[159,458,30,1199,2598,1670,318],"class_list":["post-52817","post","type-post","status-publish","format-standard","hentry","category-technology","tag-applescript","tag-finder","tag-mac","tag-mac-os-x-10-11","tag-macos-15-sequoia","tag-pasteboard","tag-terminal"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52817","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=52817"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52817\/revisions"}],"predecessor-version":[{"id":52818,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/52817\/revisions\/52818"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=52817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=52817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=52817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}