I have below files under dir_a and dir_b and i want to sort out number of dir_a and dir_b files seperately and if i do the grep it should retrun 2 files in dir_a and 1 file in dir_b.
Yes use -v switch to grep; also pass filename to grep and avoid using cat:
grep -v 45 file
/dir_a/87654321
I don't believe a not grep expression will solve your issue. Perhaps you want something like grep "^/dir_a/" , this will print any line that begins with "/dir_a/"
I have already tried those conditions but no luck, so when i want to count files in dir_a it should only give me 2 files but not 3. Is there a better wat to get the accurate number.
---------- Post updated at 03:40 PM ---------- Previous update was at 03:37 PM ----------
Btw if it begins with dir_a also i will see 3 files in dir_a even though there are only 2 because when i have a list of files in one file with the full path, that is how you will get the number.