I am tired of creating a file with nano, saving it and then making it executable. Is there a command that makes it in one step?
You mean like
touch file && chmod +x file
?Wrap it up folks, we’re done here.
Write an alias/function to do it and add to your bashrc.
function nanox() { nano "$1" chmod +x "$1" }
This is the way.
You want the install command.
At least, I think this will do it. I haven’t used it in a while.
touch file && chmod +x file
is good but this here is the one true command for the purpose.deleted by creator
that’s what I was trying to say.
install -m755 /dev/null target
was the first thing I thought of. I would never use this but it is a single command.Why would you never use it?
I’m going to write (at least part of) the script first anyway, and then I can just use chmod +x after the file is saved which is shorter.
You could define a function that takes a parameter, which touches a file with the parameters value, chmods it and then opens it with nano?
create_exec() { touch "$1" chmod +x "$1" nano "$1" }
Then you could type
create_exec file.sh
and it would do the rest for you.Use
&&
to use multiple commands one after the other, don’t use;
.-
&&
means execute if the command before ended successfully-
||
means execute if the commnad before failed-
;
just means execute the command - no matter if succeeded or failedMy dude, thanks for this. I’ve been using && for a long time now but never knew the rest, I’m still pretty new to linux comparatively.
deleted by creator
You could append the chmod command with && but that’s probably not what you wanted.