The ‘traditional’ Mac OS uses colon-delimited pathnames with the disk name as the root.
For example:
Macintosh HD:Users:username:documents:file.txt
All AppleScript’s file-based objects (file, alias, folder, etc.) will return these types of paths.
Unix apps, on the other hand, (including all shell utilities) use Unix-style pathnames that are slash-delimited. Additionally, unix paths can be absolute (they start with a /), relative to the current working directory (starts with a file or directory name), or relative to the user’s home directory (starts with the ~ symbol). For example, the above file in unix style might be:
/Users/username/documents/file.txt
Or, even:
~/documents/file.txt
The AppleScript command ‘posix path’ converts a Mac OS-style (colon-delimited) path into a Unix style path. The posix path is then suitable for including in a shell command.
A unix shell would choke on the command:
cat Macintosh HD:Users:username:documents:file.txt
but has no problem with:
cat ~/documents/file.txt
Additionally, just to be safe, if you’re including posix paths in shell commands, you should add the ‘quoted form of’ command to properly quote the path name, just in case it has spaces or other characters that might confuse a shell.
In short:
set aFile to file “Macintosh HD:Users:username:documents:file.txt”
→ file “Macintosh HD:Users:username:documents:file.txt”
posix path of aFile
→ ~/documents/file.txt
quoted form of posix path of a file
→ ‘~/documents/file.txt’
(note the quotes around the ‘quoted form’ example, which would be required if the path contained a space)