I try to create a shortcut for macOS Monterey to export data from Tim (a time tracker) and save that data to a file.
I am able to do the first step (export data), but I have no idea how to do the second step (put the text in a file).
One way could be to use a shell script to export the data:
But this gives me an almost empty file:
$ cat tim.txt
Save text to file%
There must be a [better] way to save the data to a text file.
When I try to debug the first step, I get the correct output:
How can I save the text to a file (overwrite the file or create the file if it does not exist.)
After some digging I've found that it is more straightforward than I thought.
There seems to be a bug (or a IMO bad behaviour) in the shortcuts app, the suffix of the file is always .txt, but I prefer .json, so I need a third step to rename the file.
The problem I had was to change the directory to the desired output and use a relative filename from there.
Related
I have a question about Vim.
So i have a recipients.cfg config file,
and it is being used by a script named check.sh that is sending some stats (send like an sms), and is running every minute via cron.
If i Vim recipients.cfg and leave it open for like 10 minutes, will check.sh still be able to use the recipients.cfg and send the stats?
Thank you!
Yes.
Vim only creates hidden .swp files of the file you are editing, for recovery purposes, and also to lock other Vim sessions from writing to the file at the same time.
Yes, it is safe, a good way to show you how/why is to open a file in vim, write some text and save it with :w. Now, change some of the text but don't save it. Open a new terminal and cat the file, to show the contents. You will see the file's contents are the contents at the time of the save, not the contents currently inside your instance of vim. If you type ls -a you will find a swapfile .swp or maybe a swo file etc. This is where your current changes are stored whilst vim is open, and as soon as you write (using :w) the changes from the swp file actually get put inside the file. So your check.sh will read whatever was last written to the file, not whatever is in vim.
I have been using the gvim command :w to save and it works fine saving it to the desktop. However with the vim program, when I use the command :w, I cannot find where the saved file is located.
It should save to whatever directory you started writing it in (you can see that in the command line). You can also use your computer's file search to locate it and then inspect for the file path.
As said by others: by default it saves in the directory where you started it. But if you aren't aware in which directory you started, then a way to find out is to use the :pwdcom in vim. This will output the current directory. That's where vim will store the file.
C:\Users\"windows user"\AppData\Local\Packages\KaliLinux.54290C8133FEE_ey8k8hqnwqnmg\LocalState\rootfs\home\"WSL user"
Adding another answer to get the filename as well.
As mentioned by Cary and Jeen, vim saves your file to the directory from where it is started. You can get the directory where it is saved using :pwd.
If you are interested to get name of the file, it can be done by ctrl + g when your laststatus=1, which is the default value.
I usually set laststatus=2 which always show the filename.
I'm trying to install the Google SDK
I type:
export PYTHONPATH=$PYTHONPATH:/Users/morganallen/Dropbox/google_appengine
then:
echo $PATH
And I see:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/morganallen/Dropbox/google_appengine
But when I quit terminal and re-open it and type echo $PATH I only see:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Why isn't it saving?
I've seen other answers mentioning a .bashrc file, but I can't find mine? Not sure what to do.
If you type that into the command line, it only applies for the current session (until you close the bash window). Instead, save that line of code into your .bash_profile and it should work for every single session.
A file whose name begins with a period (.) is a hidden file. Depending on the file manager/browser which you may be using, hidden files may not be shown by default. You will need to enable viewing hidden files in the preferences/options as the case may be.
If you are using a command line to list the contents, you can use ls -a instead of plain ls.
And of course, if you need to modify the hidden file using a text editor at the command line itself, (say, using vim/nano etc.) then you can always supply the full name of the file as an argument (including the period).
I open up a .txt file. Make some modifications to it. Then I'd like to outsheet it with the same name. To do this, I presume either I'd have to delete the file right before I outsheet it or replace the file in the outsheeting process. As a backup, I can manually delete the .txt execute the relevant code.
I'd like to do this via Stata, however. Is it possible to either:
1. Delete a .txt file within a Stata .doe--say with a shell command ?
2. Overwrite a .txt file in the outsheeting process ?
I am outsheeting as in:
outsheet v1 v2 using "file.txt", nolabel delim(",")
I run Stata in Windows on an XP machine.
Add the replace option anywhere after the comma.
You can can also shell out to the OS. Type "h shell" to see how.
Or just use rm/erase directly.
shell: /bin/tcsh
I'm attempting to search for a string in a Cocos2D tmx file and replace it with text from another file.
Before the touch commands in Run Script, I have the following:
sed -i '' 's{<tileset firstgid="1.*<layer name="background"{Resources/maps_sideScrolling/tileProperties.txt{g' Resources/maps_sideScrolling/ruinsItemCave2.tmx;
I'm fairly certain the file ruinsItemCave2.tmx is found, because if I change the file path I get an error when I build the project. As of now, ruinsItemCave2.tmx is not affected in any way.
Eventually I will want to change ruinsItemCave2 to a wildcard filename so it affects every file name, though I'm not sure how to write Resources/maps_sideScrolling/*.tmx the proper way.
I also know that without even writing a file path of tileProperties.txt, but just writing "test" does nothing to my ruinsItemCave2 file, so I can't even get that far as of now. Does it have to do with using tcsh?