linux - Weird issue with "sed" command -


on script, -for unknown reason- gives me errors when reaches sed command:

function nzb() {   ( [ -z "$1" ] ) && echo "no argument given!" && return 1   hash="$(echo -n "$1" | md5sum | cut -d" " -f1)"   mkdir "${hash}" && rar -m0 -v200m "${hash}"/"${hash}".rar "$1" && rm -rf "$1" &&   par2 c  -r10 -l "${hash}"/"${hash}".par2 "${hash}"/* && ~/newsmangler-master/mangler.py   -c ~/.newsmangler.conf "{hash}" && sed -i "1i$1\n${hash}\n" ~/hashs.txt } 

.

error: "{hash}" not exist or not file! error: no valid arguments provided on command line! 

but when -out of curiosity- removed sed's preceding commands, worked suppose to:

function nzb() {   ( [ -z "$1" ] ) && echo "no argument given!" && return 1   hash="$(echo -n "$1" | md5sum | cut -d" " -f1)"   sed -i "1i$1\n${hash}\n" ~/hashs.txt } 

.

any ideas?

edit: seems problem located in area:

 . . . && ~/newsmangler-master/mangler.py -c ~/.newsmangler.conf "{hash}" && . . . 

because working:

function nzb() {   ( [ -z "$1" ] ) && echo "no argument given!" && return 1   hash="$(echo -n "$1" | md5sum | cut -d" " -f1)"   mkdir "${hash}" && rar -m0 -v200m "${hash}"/"${hash}".rar "$1" && rm -rf "$1" &&   par2 c -r10 -l "${hash}"/"${hash}".par2 "${hash}"/* && sed -i "1i$1\n${hash}\n" ~/hashs.txt } 

replace "{hash}" "${hash}"


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -