Jump to content

Tabulation ignored with echo command


Recommended Posts

Posted

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?

Posted

Have you tried the "enable interpretation" switch, -e?

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

Otherwise I THINK you may have to parse the text with sed or awk.

Posted

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!

Posted

Thank you RodgerWW, I appreciate but I don't know how to implement this solution (I'm not familiar with applescripts).

 

I finally decided to use the character "|" instead of the tabulation. It's not as good as the tabulation... but it will be OK.

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...