Skip to main content
included da move for completeness
Source Link
user unknown
  • 10.8k
  • 3
  • 37
  • 59
for dateNfile in $(grep dateishere *html | sed -r 's/^([^:]*):(.*)dateishere/\2:\1/' | sort -n) do echo name=${dateNfile/*:/}   # echo date=${dateNfile/:*/} mv $name /other/location done 

So I guess there is just one line per file, containing 'dateishere', and that the line starts with the date, but the sed command could be modified, to cut the date even in other cases.

If you have blanks in the filenames, or linebreaks and such, things get a bit more complicated, so I would like to ignore these, if possible. But from your assertion, this isn't the case.

for dateNfile in $(grep dateishere *html | sed -r 's/^([^:]*):(.*)dateishere/\2:\1/' | sort -n) do echo name=${dateNfile/*:/} echo date=${dateNfile/:*/} done 

So I guess there is just one line per file, containing 'dateishere', and that the line starts with the date, but the sed command could be modified, to cut the date even in other cases.

for dateNfile in $(grep dateishere *html | sed -r 's/^([^:]*):(.*)dateishere/\2:\1/' | sort -n) do name=${dateNfile/*:/}   # echo date=${dateNfile/:*/} mv $name /other/location done 

So I guess there is just one line per file, containing 'dateishere', and that the line starts with the date, but the sed command could be modified, to cut the date even in other cases.

If you have blanks in the filenames, or linebreaks and such, things get a bit more complicated, so I would like to ignore these, if possible. But from your assertion, this isn't the case.

Source Link
user unknown
  • 10.8k
  • 3
  • 37
  • 59

for dateNfile in $(grep dateishere *html | sed -r 's/^([^:]*):(.*)dateishere/\2:\1/' | sort -n) do echo name=${dateNfile/*:/} echo date=${dateNfile/:*/} done 

So I guess there is just one line per file, containing 'dateishere', and that the line starts with the date, but the sed command could be modified, to cut the date even in other cases.