Определите переменную и используйте подоболочку для выполнить sed
и перенаправить в файл.
Очень важно использовать "
(двойные кавычки) для защиты переменной $ value
:
value = $ (sed 's / old / new / g' file) && echo "$ value"> file
Or
Execute echo
с подоболочкой, которую вы собираетесь выполнить 'sed' и перенаправление в файл:
echo "$ (sed 's / old / new / g' file)"> file
Я хочу подключить этот sshfs к:
Собрав воедино информацию, представленную в превосходном посте somethingSomething, вместе с необходимыми параметрами, мы получили это:
stephen@server:/export/inbox /mnt/inbox fuse.sshfs x-systemd.automount,x-systemd.requires=network-online.target,_netdev,user,idmap=user,transform_symlinks,port=2314,identityfile=/home/stephen/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000,exec 0 0
Дополнительные параметры::
x-systemd.automount
создает модуль автомонтирования для systemd x-systemd.requires=network-online.target
попытки монтирования только после установления сетевого подключения exec
сделать файлы на смонтированном диске исполняемыми. Запись в /etc/fstab
, которую вы ищете, это:
Использование параметров ,port=PORTNUMBER
и ,IdentityFile=/root.ssh/id_rsa
:
sshfs#USER@IP-ADDRESS:/export/inbox /mnt/inbox fuse.sshfs delay_connect,_netdev,user,IdentityFile=/root.ssh/id_rsa,idmap=user,allow_other,default_permissions,port=PORTNUMBER,uid=0,gid=0,rw,nosuid,nodev 0 0
Установка каталога через ssh
с помощью SSHFS
с пульта
sshfs#USER@IP-ADDRESS: /export/inbox fuse defaults,user,noauto,
uid=einstein,gid=einstein,allow_other,IdentityFile=/home/alfred/.ssh/id_dsa 0 0
sshfs#USER@IP-ADDRESS: /export/inbox fuse defaults,user,uid=USER,gid=USER,allow_other,IdentityFile=/home/USER/.ssh/id_dsa 0 0
Руководство Мида по безопасной оболочке (SSH)
Как смонтировать удаленный каталог sshfs в fstab
Автомонтирование sshfs с помощью fstab без монтирования -a
SSHFS принимает многие параметры строки команды -, которые вы, возможно, захотите проверить. Например,если бы сервер SSH на удаленном компьютере работал на порту 12345 вместо порта 22, вы бы сделали это:
sshfs USER@IP-ADDRESS: /export/inbox -p PORTNUMBER
Вот команда -опции строки:
Параметры SSHFS:
-p PORT
equivalent to '-o port=PORT'
-C
equivalent to '-o compression=yes'
-F ssh_configfile
specifies alternative ssh configuration file
-1
equivalent to '-o ssh_protocol=1'
-o reconnect
reconnect to server
-o delay_connect
delay connection to server
-o sshfs_sync
synchronous writes
-o no_readahead
synchronous reads (no speculative readahead)
-o sshfs_debug
print some debugging information
-o cache=BOOL
enable caching {yes,no} (default: yes)
-o cache_timeout=N
sets timeout for caches in seconds (default: 20)
-o cache_X_timeout=N
sets timeout for {stat,dir,link} cache
-o workaround=LIST
colon separated list of workarounds
none
no workarounds enabled
all
all workarounds enabled
[no]rename
fix renaming to existing file (default: off)
[no]nodelaysrv
set nodelay tcp flag in ssh (default: off)
[no]truncate
fix truncate for old servers (default: off)
[no]buflimit
fix buffer fillup bug in server (default: on)
-o idmap=TYPE
user/group ID mapping, possible types are:
none
no translation of the ID space (default)
user
only translate UID of connecting user
file
translate UIDs/GIDs based upon the contents of uidfile and gidfile
-o uidfile=FILE
file containing username:uid mappings for idmap=file
-o gidfile=FILE
file containing groupname:gid mappings for idmap=file
-o nomap=TYPE
with idmap=file, how to handle missing mappings
ignore
don't do any re-mapping
error
return an error (default)
-o ssh_command=CMD
execute CMD instead of 'ssh'
-o ssh_protocol=N
ssh protocol to use (default: 2)
-o sftp_server=SERV
path to sftp server or subsystem (default: sftp)
-o directport=PORT
directly connect to PORT bypassing ssh -o slave communicate over stdin and stdout bypassing network
-o transform_symlinks
transform absolute symlinks to relative
-o follow_symlinks
follow symlinks on the server
-o no_check_root
don't check for existence of 'dir' on server
-o password_stdin
read password from stdin (only for pam_mount!)
-o SSHOPT=VAL
ssh options (see man ssh_config)