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}"