表示される内容を変更できますか$PS1
?ユーザーが入力した内容です。my_function
後でいくつかのコマンドを実行することをお勧めします。もちろん、バックスペースを使用して修正/削除できる必要があります。
root@linux:
root@linux: ls
aplha beta gamma
root@linux: my_function
root@linux: echo_something_here (It should be deletable by me)
ベストアンサー1
に基づいてこの回答あなたはそれを使用することができますexpect
(最初にインストールする必要があるかもしれません):
#!/usr/bin/expect -f
# Get a Bash shell
spawn -noecho bash
# Wait for a prompt (in my case was '$', but your example only put ':')
expect ": "
# store the first argument in a variable
set arg1 [lindex $argv 0]
# Type something
send $arg1
# Hand over control to the user
interact
exit
これで呼び出すことができます(として保存したと仮定my_function
)。
root@linux: ./my_function "some text here"
root@linux: some text here
唯一の負の影響は、新しい暴食を開始することです。