I have 100s of files in a directory, and I want to keep only those where a part of first file matches with another file and if condition is not fulfilled than mv all files without its corresponding file, such as I have:
man_xyz_1.txt
sig_xyz_1.txt
man_abc_1.txt
man_ttc_1.txt
man_ddd_1.txt
sig_ddd_1.txt
here, I want to keep only first two files (man_xyz_1.txt and sig_xyz_1.txt; man_ddd_1.txt and sig_ddd_1.txt
) as their part of filenames (*_xyz_1.txt and *_ddd_1.txt
) are matching while want to mv (man_abc_1.txt and man_ttc_1.txt
) in to another directory as they don't have corresponding file with prefix sig_*
.
Any help is welcome.
Thanks,