开发者

problem with directory name in awk

I am trying to write a script that takes 2 arguments : the first file contain some files extensions , and the second a directory .

My script move the files which their extension existed in the extension's file to the directory.

This is my script:

BEGIN{
}
{
 file_ext = $1
 folder = $2 
开发者_开发问答 isexist = "[ -e " $1 " ]"

 if( ( system(isexist) ) != 0 )
 {
  getline < file_ext
  system("find *." $0" -exec mv {} " folder " \;") 
  next
 }
}
END{
}

But when I call the script in the shell , I am getting this error :

mv: missing destination file operand after `koko.cpp'

When I put folder name directly it works fine , but when I pass it by argument it doesn't work, why?


Command line arguments are accessed via the ARGV array:

BEGIN {
    # "pop" the directory name off the arguments list
    folder = ARGV[2] 
    ARGV[2] = ""
}
{
    # then process the "file_ext" file
    system("find . -name \\*." $0 " -exec mv {} " folder " \\;") 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜