I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file.
Sample control file:
TEST
SEND
SFFFILE
CONTL
The directory contains followign files:
TEST
SEND
SFFFILE
CONTL
Link
seq
test
param
When i run a script it has to create a file with the following files.
Link
seq
test
param
Please give me any suggestion how to do this .Control file contains more file and dir also contains more file.Please tell the efficient way to do this.
Trivially, take out the -x option which requires the whole line to match, and add an -i option to make matching ignore case. However, that does not anchor searches to beginning of line, so e.g. a file named bestest will match the pattern test. Maybe you could accept a change to the control file format, to support full regular expressions? Then the control file should contain
^test
^send
^sfffile
^contl
It's possible to come up with a different workaround if this is not acceptable. If your needs are very specific, perhaps a small awk script would be best.
ls | awk 'NR==FNR { pat[++n] = "^" tolower($0); next; }
{ for (p in pat) if (tolower($0) ~ pat[p]) next; print }' ctlfile -
(With this script, you should keep the original control file.)
Your requirements are not clear; need to be precise about them or it all gets lost in translation...and please use code tags.
The entries in the control file should match only the name of the file but not the extension...correct??
Thi following command is not returning any thing.
ls -1 | \
awk '{
if (NR==FNR) {
f[$1]
f[FILENAME]
} else
if (!($1 in f))
print $1 >> "outfile"
}' cntrlfile -
Thanks