Higashifukai Posted January 30, 2015 Posted January 30, 2015 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?
RodgerWW Posted January 30, 2015 Posted January 30, 2015 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.
Higashifukai Posted January 30, 2015 Author Posted January 30, 2015 Thank you RodgerWW... I gave it a try and it didn't work. I guess I will have to learn how to parse the text with sed...
RodgerWW Posted January 30, 2015 Posted January 30, 2015 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!
Higashifukai Posted January 30, 2015 Author Posted January 30, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now