/root/mp3/ path contains below file. want move file contain letter "in" other folder
2017-02-10-12-11-05-in.talaw 2017-02-10-12-11-05-out.talaw 2017-02-10-12-12-05-in.alaw 2017-02-10-12-12-05-out.alaw $files=/root/mp3/* f in "$files" ef=$(ls $f | awk -f"." '{print $1}' | awk -f "-" '{print $nf}') #to check in file if [ $ef = "in" ] #if file contian "in" letter move other folder ) mv /files /sotrage fi done
getting error many arguments @ if [ $ef = "in" ] if tried if [ "$ef" == "in" ] not getting current output
using if [ $ef = "in" ] compare if file contains "in"
then should move files conatians in other folder
really want mv -t /destination /root/mp3/*-in.*
you having problems due you're storing pattern in variable:
$files=/root/mp3/* f in "$files";
at point, $f
contains literal string "/root/mp3/*"
-- pattern has not been expanded yet because of quotes around "$files"
then, this
ef=$(ls $f | awk -f"." '{print $1}' | awk -f "-" '{print $nf}')
$f
unquoted, shell expands pattern , ls
sees list of files. you're passing awk
several lines of text. $ef
contain newlines. try echo "$ef"
@ point.
Comments
Post a Comment