Используйте обратные ссылки. Ответ на Ваш первый вопрос (2-й, 3-й символ то же):
egrep '^.(.)\1'
http://www.regular-expressions.info/brackets.html является простым введением к обратным ссылкам.
Вы пропустили всего один символ =)
ssh user@socket command < /path/to/file/on/local/machine
Один путь, который работает независимо от команды, состоит в том, чтобы сделать файл доступным на удаленной машине через удаленную файловую систему. Так как у Вас есть соединение SSH:
# What if remote command can only take a file argument and not read from stdin? (1_CR)
ssh user@socket command < /path/to/file/on/local/machine
...
cat test.file | ssh user@machine 'bash -c "wc -l <(cat -)"' # 1_CR
Как альтернатива bash
замена процесса <(cat -)
или < <(xargs -0 -n 1000 cat)
(см. ниже), можно просто использовать xargs
и cat
передавать содержание по каналу указанных файлов к wc -l
(который является более портативным).
# Assuming that test.file contains file paths each delimited by an ASCII NUL character \0
# and that we are to count all those lines in all those files (provided by test.file).
#find . -type f -print0 > test.file
# test with repeated line count of ~/.bash_history file
for n in {1..1000}; do printf '%s\000' "${HOME}/.bash_history"; done > test.file
# xargs & cat
ssh localhost 'export LC_ALL=C; xargs -0 -n 1000 cat | wc -l' <test.file
# Bash process substitution
cat test.file | ssh localhost 'bash -c "export LC_ALL=C; wc -l < <(xargs -0 -n 1000 cat)"'
scp
прежде. – rush 26.10.2012, 18:53/dev/stdin
или-
. May или не может работать (/dev/stdin
файл, но поиск его перестанет работать), – derobert 26.10.2012, 19:03