I'm using R to do some file processing in Linux and am trying to read in the output of find . -type f -print > ~/Music_Archives_search_problem/ls.output.find.txt
This command yields a text file with each line representing the full path name of all files in the directory and subdirs. Unfortunately, there seem to be some special characters that interfere with scan recognizing '\n' as newline. At least that's what I assume the problem is, but I can't identify which those might be or how to correct the problem. Below is my code and the problem output followed by sessionInfo(). This is executed in a loop, with i starting from zero. I also tried with 'allowEscapes = TRUE', but that made no difference. As you can see, the first FLAC file is followed by a '\n', which is ignored. This seems to happen about once in every 20 file names, so it does work properly most of the time. Also, when the file is opened in emacs, the newlines are recognized. current.line <- scan("~/Music_Archives_search_problem/ls.output.find.txt", skip = i, nlines = 1, what = 'character', sep = "@", allowEscapes = FALSE) [1] "./Christian/Christian Gospel/Chanticleer/Chanticleer - How Sweet the Sound; Spirituals & Traditional Gosp - 04 - Soon One Mornin Medley; Soon One Mornin-What You Gon Do When the ....flac\n./Christian/Christian Gospel/Chanticleer/Chanticleer - How Sweet the Sound; Spirituals & Traditional Gosp - 05 - Didnt It Rain.flac" > sessionInfo() R version 2.9.0 (2009-04-17) x86_64-unknown-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices datasets utils methods base ------------------------------------------------------------ Mark W. Kimpel MD ** Neuroinformatics ** Dept. of Psychiatry Indiana University School of Medicine 15032 Hunter Court, Westfield, IN 46074 (317) 490-5129 Work, & Mobile & VoiceMail (317) 399-1219 Home Skype: mkimpel "The real problem is not whether machines think but whether men do." -- B. F. Skinner ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.