Jump to content

Tabulation ignored with echo command


Recommended Posts

Hi,

 

I have a very simple workflow for pasting the clipboard content at the end of a txt file, with echo.

echo "{query}" >>/Users/.../mytextfile.txt && osascript -e 'tell application "Terminal" to close window 1'

It works perfectly... but when the string contains a tabulation, the tabulation is ignored. How can I keep the tabulation?

Link to comment

OK, I think the issue is using just bash.  If you shift your script from bash to AppleScript (osascript), you can set a value defined from the clipboard, and output it as text to keep the tablature. IE:

set myValue to the clipboard as text
do shell script "echo " & myValue & " >> /Users/.../mytextfile.txt"

With bash alone, one would have to grab the clipboard and search for tabs and replace with \t on each instance ... it's messy!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...