shell command for opening file and add content at the end

47 views
Skip to first unread message

Jan Erik Moström

unread,
Oct 9, 2024, 3:26:13 PM10/9/24
to BBEdit Talk
Hi all,

I'm trying to automate a few things and I'm trying to figure out if there is a way to, in one command, open and/or create a specific file and add some text at the end.

I don't know if I'm missing something, but I can't figure out how to do it.

With "bbedit -c filename" I can create the file

With "bbedit --append" I can pipe some data to bbedit that will appended to the active document (so I would need to open it first)

Is there some way to do this in one operation or do I need two operations?

= jem

Patrick Woolsey

unread,
Oct 9, 2024, 5:00:27 PM10/9/24
to bbe...@googlegroups.com
Good afternoon and please pardon the obvious :-) but is there any reason not to just create a script which compounds the desired commands and run that within BBEdit?

========
#!/bin/sh

bbedit -c ~/Desktop/only_one.txt

echo "Nullam.txt" | bbedit --append
========

Regards,

-- Patrick

"Jan Erik Moström"

unread,
Oct 9, 2024, 6:24:29 PM10/9/24
to bbe...@googlegroups.com
On 9 Oct 2024, at 23:00, Patrick Woolsey wrote:

> Good afternoon and please pardon the obvious :-) but is there any reason not to just create a script which compounds the desired commands and run that within BBEdit?
>
> ========
> #!/bin/sh
>
> bbedit -c ~/Desktop/only_one.txt
>
> echo "Nullam.txt" | bbedit --append
> ========

Only that I hope to later do some scripts that would involve some slightly more complex stuff, and I'm more comfortable using Python than sh (there are a few more things I want to do before getting BBEdit to do it's thing). While sh and I were friends, the keywords are "were" and the missing "close", I'm pretty much a complete newbie at this time.

It's also bin (sigh, I'm trying to learn German) a while since I used subprocesses in Python so I was trying to brush up on that part as well, and this script seemed to be a simple start.

But you're completely right, for this very simple script this would work just fine.

= jem

History Stamp

unread,
Oct 9, 2024, 8:01:51 PM10/9/24
to bbe...@googlegroups.com

--
This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/CE8DDCA0-7D5A-478E-8144-D1F1E0948D13%40mostrom.pp.se.
Reply all
Reply to author
Forward
0 new messages