Skip to main content
8 events
when toggle format what by license comment
Jun 27, 2019 at 5:08 history edited nohillside CC BY-SA 4.0
added 9 characters in body
Jun 26, 2019 at 18:44 comment added Gordon Davisson According to the file output in the question, the file (or at least the test file) has CR line endings rather than LF. It'll either need to be converted, or use read -t $'\r' to make it recognize CR endings. Also, I'd add a third variable argument to read to absorb anything past the second column.
Jun 26, 2019 at 13:52 history edited nohillside CC BY-SA 4.0
added 20 characters in body
Jun 26, 2019 at 13:32 comment added user3439894 I try not to assume anything when it comes to code in an answer and whether or not it a "one-off solution" you should, under the circumstances, at a minimum include the -n option in the mv command.
Jun 26, 2019 at 13:03 comment added nohillside @user3439894 The answer assumes a one-off solution, and even then it‘s better to split the CSV into files < 1000 lines. Getting that snippet ready for production code is a totally different thing, I would definitively use an environment with a proven CSV library for that, and all a lot of error handling as well
Jun 26, 2019 at 12:35 comment added user3439894 However, since the default Scrollback buffer is 10,000 lines and the CSV file has 13,000 lines, I'd also use tee to create a log.txt file, e.g. mv -nv "$s" "$t/" 2>&1 | tee log.txt The log.txt could then be used to more easily rectify any issues. It's that or code the script differently to accommodate any errors that may occur.
Jun 26, 2019 at 12:35 comment added user3439894 Using echo is fine to see if the command is being formatted properly; however, it's not going to stop errors from occurring due to other issues, i.e., "PS: If the same source folder is listed several times you will loose data.", or other possible errors. At a minimum, I would use the -n option with the mv command, then there will be no data loss. Going a bit further, I would also add the -v option so as to be informed if the -n option came into play, e.g.: mv -nv "$s" "$t/"
Jun 26, 2019 at 9:19 history answered nohillside CC BY-SA 4.0