想要写个脚本,执行后进入到vim
文本编辑界面
例如, 脚本名叫wt
, 在脚本中我创建了一个文件123.txt
, 如何在脚本执行完成后进入到对123.txt的vim编辑界面
目前想到的是:
在脚本中调用vim,但已有错误提示
将新建文件的路径+名称返回给一个变量,然后用vim
打开
我的问题是:
脚本中能否调用vim?
如何获取执行脚本的返回值?
或者有其他的更好的解决方法?
刚开始学shell,希望大家能给个解答或者是推荐些相关的资料,拜谢!
阿神2017-04-17 15:19:12
I don’t know if I can help LZ
New file
vi wt
Edit the file, copy the following code into the wt file, save and exit
# Status, 123: success, 0: error
status=123
vi 123.txt
exit $status
Note: The last line specifies the exit status of the shell script. The status value of 123 is only for demonstration
Give permission
chmod +x wt
ll | grep 'wt'
Execute
./wt
View execution status
echo $?
巴扎黑2017-04-17 15:19:12
Vim can be called in the script, but you can only play with the parameters. .
The return value of the script can be obtained using $?
I don’t understand what you want to do. Is it just to open a file for editing with vim?
Shell allows you to check information online. You can search a lot on Baidu and Bing. .
ringa_lee2017-04-17 15:19:12
What you mean by this is that after the script is executed, you can enter vim to edit the files you created in the script, right? You no longer need to enter vim on the command line