Niklas Posted July 28, 2020 Share Posted July 28, 2020 Hey, I try to create a workflow that create a new file in my Notes app. It works. But I want that file name is automatically generated from date, time and my query. I add a bash script what takes all these things and use the output as file name: But the problem is, that the query output is shown in a new line. My code: date +"%Y%m%d%H%M" echo -n $date-{query} My output: 202007282050 -fdjspj What I want as output: 202007282050-fdjspj Is there somebody who can help me to fix this code? Link to comment
deanishe Posted July 28, 2020 Share Posted July 28, 2020 (edited) Your mistake is that your date +"%Y%m%d%H%M" command also prints its output. You aren’t actually assigning it to a variable (which is what you seem to want/think is happening). The correct version of what you're trying is: # use var=$( ... ) to assign output of a command to a variable date="$( date +"%Y%m%d%H%M" )" echo -n $date-{query} There’s no need for two commands, however. You can stick it all in one echo statement. And finally, you shouldn’t use {query} (it’s only there for legacy support). Use “with input as argv” instead. In that case, your command becomes: echo -n "$( date +%Y%m%d%H%M )-$1" Edited July 28, 2020 by deanishe Niklas 1 Link to comment
Niklas Posted July 28, 2020 Author Share Posted July 28, 2020 Oh, this works fantastically! Thanks a lot! Link to comment
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