Я установил этот скрипт, который, похоже, работал на меня как на Ubuntu 11.10 oneiric, так и на Ubuntu 13.10. Тем не менее, я уверен, что у вас полно проблем и установка кода, который вам может и не понадобиться. Если кто-то лучший программист bash заходит туда и вставляет некоторые if [ ...] заявления, чтобы не устанавливать все пакеты.
#!/bin/bash
# Word of caution, I am not an experienced shell programmer. All I can #
# guarantee is that this script has worked for me, and that it has #
# done so on multiple Ubuntu machines (one 11.10 and one 13.10), so #
# hopefully it will work for you too #
# Install some packages as instructed on various web sites
sudo apt-get -y install qt4-qmake libqt4-dev build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev
sudo apt-get -y install libtool autotools-dev autoconf
sudo apt-get -y install libdb4.8-dev # Generally this step fails
sudo apt-get -y install libdb4.8++-dev # Generally this step fails
sudo apt-get -y install libboost1.37-dev # Sometimes this step fail
sudo apt-get -y install libboost-all-dev # Sometimes this step fail
sudo apt-get -y install libminiupnpc-dev
sudo apt-get -y install libdb++-dev
sudo apt-get -y install libprotobuf-dev
sudo apt-get -y install libqrencode-dev
# Build berkley db4.8
# Technically, this should only be installed if the above #
# libdb4.8XX-dev packages failed to install but nothing beats a little #
# overkill =) #
cd ~/Downloads
if [ ! -e db-4.8.30 ]
then
wget http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz
tar zxvf db-4.8.30.tar.gz
rm -f db-4.8.30.tar.gz
fi
cd db-4.8.30/build_unix
../dist/configure --prefix=/usr/local --enable-cxx # If this doesn't work, try removing or changing prefix
make
sudo make install
cd ~/Downloads
rm -fr db-4.8.30/ # If it still doesn't work, try commenting out this line
locate libdb4.8-dev # Comment this out as it may cause problems
if [ $? -ne "0" ]
then
Failed to install db-4.8.30
exit -1
fi
# Build bitcoin
cd ~/Downloads
if [ ! -e bitcoin ]
then
git clone https://github.com/bitcoin/bitcoin ~/Downloads/bitcoin
fi
cd bitcoin
./autogen.sh
./configure # Non Ubuntu 13.xx versions
# ./configure --with-boost-libdir=/usr/lib/x86_64-linux-gnu # Ubuntu 13.xx version
make
cd ~/Downloads
rm -fr bitcoin
Хорошо, назовите меня noob, но я попробовал предложение John1024, и это дало мне ошибку, поэтому я попытался выяснить это самостоятельно. Я создал файл с именем readline.sh, который содержал следующее:
#!/bin/bash
file=$1 # $1 contains the argument passed
> line.txt # create/empty line.txt
IFS=$'\n' # set Internal Field Separator to '\n'
for line in `cat $file` # assign each line in $file to $line
do
echo $line >> line.txt # print $line to line.txt
# this one's tricky because you need to pipe just the line
# (without a '\n') into xxd and then print it to line.txt
echo `printf "%s" "$line" | xxd -p` >> line.txt
done
cat line.txt # we want to see the contents of line.txt now
Теперь, чтобы запустить его, я вызвал ls | ./readline.sh и вывел следующее:
bar
626172
baz
62617a
foo
666f6f
line.txt
6c696e652e747874
readline.sh
726561646c696e652e7368
Теперь, Я хочу отметить, что этот скрипт не имеет никакого способа проверить, что $ 1 даже существует, и, вероятно, есть другие проблемы с ним, но, полагая, что я правильно понимаю ваш вопрос, кажется, что суть решения заключается в том, чтобы пропустить вывод из ls по строкам в xxd -p. Весь дополнительный пух был: а) для меня, чтобы он работал, прежде чем публиковать его, и б) показать принцип в действии.