So here is the task which I can’t solve. I have a directory with .h files and a directory with .i files, which have the same names as the .h files. I want just by typing a command to have all .h files which are not found as .i files. It’s not a hard problem, I can do it in some programming language, but I’m just curious how it will look like in cmd :). To be more specific here is the algo:
- get file names without extensions from ls *.h
- get file names without extensions from ls *.i
- compare them
- print all names from 1 that are not met in 2
Good luck!
diff <(ls dir.with.h | sed 's/\.h$//') <(ls dir.with.i | sed 's/\.i$//')executeslson the two directories, cuts off the extensions, and compares the two lists. Thengrep '$<'finds the files that are only in the first listing, andcut -c3-cuts off the"< "characters thatdiffinserted.