Skip to main content
13 events
when toggle format what by license comment
Oct 22, 2021 at 17:52 comment added alecxs linux.die.net/man/1/grep you can also add quotes in your grep search pattern, although you probably must escape them \"
Oct 22, 2021 at 17:52 vote accept botloggy
Oct 22, 2021 at 17:51 comment added botloggy You are totally right. I checked the file and the column contents were read with having quotes inside each item. I removed them by adding tr -d \" to the line cut -d ',' -f6,26 $AAA_File | tr -d \" > index.txt and it worked. Thank you so much! Appreciate it!
Oct 22, 2021 at 17:38 comment added alecxs If I copy data below "Information in CSV" in index.txt it works for me. for grep -x flag index.txt must not contain gaps or trailing whitespaces because every byte is taken literally. another cause may wrong line ending CRLF instead LF. just start from scratch writing your own script, you will figure it out
Oct 22, 2021 at 17:36 comment added botloggy I am sorry, I tried removing the flags but it seems like it is not changing.
Oct 22, 2021 at 17:31 comment added botloggy Yes, I had tried replacing the ./ with the proper path earlier. Will try your other recommendation. Thanks!
Oct 22, 2021 at 17:27 comment added alecxs replace ./*/*/ with proper path, for example path/to/parent/*/*/ (including trailing slash) where the first star is for dir and second star for subdir. or remove -F -x flags from grep, not sure why it fails. you can dry run grep in cmd line without -q flag. you can add echo $dir for debugging purposes or run script via sh -x script.sh
Oct 22, 2021 at 17:24 comment added botloggy Yes, Indeed it can be dangerous. However, I have just a bunch of symbolic links in them so may be fine. Thanks for sharing the grep tutorials. Very helpful.
Oct 22, 2021 at 17:03 comment added botloggy Thanks for the solution and detailed explanation. It was really helpful. However, I tried uncommenting the #delete line but it's not working. I also printed out till dir and subdir by parsing and the directories and sub-directories are printed out correctly. I think there may be some problem in the grep step. Sorry, I may be wrong though.
Oct 22, 2021 at 15:58 comment added alecxs just saw your csv file contains more columns than in question, added line cut -d ',' -f6,26 file.csv > index.txt
Oct 22, 2021 at 15:56 history edited alecxs CC BY-SA 4.0
added 46 characters in body
Oct 22, 2021 at 15:14 comment added alecxs Substring Removal, grep, find
Oct 22, 2021 at 15:09 history answered alecxs CC BY-SA 4.0