开发者

How do I create shortcut commands in the Ubuntu terminal?

开发者 https://www.devze.com 2023-02-25 05:55 出处:网络
开发者_开发问答For example, instead of typing all 5 commands in my terminal: command 1 command 2
开发者_开发问答

For example, instead of typing all 5 commands in my terminal:

command 1
command 2
command 3
command 4
command 5

I just want to enter one command that runs all 5 commands above:

command everything

Is that possible? What would I need to edit in Ubuntu to do so?


If you're running a bash shell, you can type

alias commandall='command1 ; command2 ; command3 ; command4; command5'

Then commandall will run these commands

You can put the alias in your ~/.bashrc file and it will be there whenever you log in.


create a bash script.

#!/bin/bash
command1
command2
command3

then set its mode to executable

chmod a+x commandall

then you can call it from the command line

./commandall

if you put it in a directory in your PATH, you can call it like any other command.

~/bin


Write a shell script, mark it executable, put in in your path and then run it?

Alternatively you might write a shell function, put it in your ~/.bashrc.


You are probably looking for bash aliases -- try starting here :)


If you want every command be executed in the order, command1 && command2 && command3 && command4 && command5 should do. You could save it in a shell script and call the script when you need.

If the order of execution is not so important,

command1 &
command2 &
command3 &
command4 &
command5 &

should do.

You could as well mix and match if you need some other order of execution.


According to this:

$ (stsrun -v devel area1.exp; stsrun -v devel prime1.exp; stsrun -v devel treat.exp) &
0

精彩评论

暂无评论...
验证码 换一张
取 消