Skip to main content
7 events
when toggle format what by license comment
May 22, 2020 at 1:38 comment added Freddy You can read the last N lines of a file with tail -nN file and you could change the last line to done < <(tail -n5000 models_linearanalysis_Cep.dat) using a process substitution <(...).
May 22, 2020 at 1:19 comment added thecep1 One small question. Let's say I don't want to read all the rows in models_linearanalysis_Cep.dat, perhaps for example the last 5000 rows. I know that a for loop would be appropriate for this situation, but I am naive about the syntax. Woulf you simply replace while read -ra fields with for read -ra field in fields?
May 18, 2020 at 18:24 vote accept thecep1
May 18, 2020 at 17:40 comment added Freddy The / is the separator for the substitution ("s/regexp/replacement/i"), either escape it as LOGS_A\/LOGS_${fields[0]} or change the separator to a different character ("s#regexp#replacement#i").
May 18, 2020 at 17:20 comment added thecep1 Now, say I want to put all the LOGS_ and photos_ into directories: named LOGS_A. I and photos_A. I tried to change LOGS_${fields[0])} to LOGS_A/LOGS_${fields[0])}, but the LOGS_A directory is not even created and I get the error sed: -e expression #6, char 49:unkown option to 's'. How would you modify the script to do this?
May 18, 2020 at 15:37 vote accept thecep1
May 18, 2020 at 17:15
May 18, 2020 at 3:26 history answered Freddy CC BY-SA 4.0