how to use placeholder in command line in linux?
Suppose I want to copy a file:
scp abc root@10.10.1.1:/home/user/app_abc
is开发者_运维问答 there a way can simplfy this command ,something like :
scp abc root@10.10.1.1:/home/user/app_%1
BTW: I don't want to write a shell for it
Thanks
You don't have to write separate script file but you can always write one liner:
name=abc;cp $name app_$name
Did you mean scp by the way? I never used cp with this notation.
Try the following:
export BOO="abc" && scp $BOO root@10.10.1:/home/user/app_$BOO
you can have this command in script file (copy.sh) and use it with any file name you want as an input argument. you just need to follow the instruction :
Create the the Bash Script File :
$ gedit copy.sh
Add your code to file and save it:
#!/bin/sh
scp $1 root@10.10.1.1:/home/user/app_$1
Make file executable for any one :
$ chmod 777 copy.sh
And execute it:
$ ./copy.sh abc
精彩评论