A Few Tools for Your Computer - Page 7 - Politics Forum.org | PoFo

Wandering the information superhighway, he came upon the last refuge of civilization, PoFo, the only forum on the internet ...

Anything from household gadgets to the Large Hadron Collider (note: political science topics belong in the Environment & Science forum).

Moderator: PoFo The Lounge Mods

#15276101

One might argue that 'a-line-ending-in-a-number' isn't specific-enough, since someone might quickly put in a photo filename (like the sample 'DSC_1459' above) and if they left-off the '.JPG' extension, then *that* line would end with a number, '9', which would throw-off the regular, desired results provided by that line of Bash scripting.

So, to 'upgrade', let's focus on the 'fixed', *predictable* portions of any given entry, meaning the 'code block' at the end:

CODE=4

cat 220315_index | tr '\n' '~' | sed 's/[0-9]~~/&\n\n/g' | grep "$CODE~~$"



viewtopic.php?p=15217941#p15217941



CORRECTION:

Just realized that the existing script lines don't really address the 'DSC_1459' issue above -- what if a line happens to end in a digit, followed by two carriage returns, within an entry? It would then be transformed into an undesired end-of-entry designation (the entry's 0-9 taxonomy-line digit followed by two tilde '~' characters) (*any* normally-unused character could be used instead of the tilde character).

So here's the fix, if you didn't happen to get to it before me:


sed 's/|[0-9]~~/&\n\n/g'


Note the '|' 'pipe' character now as the very first character to be found, *necessarily* followed by a single digit, 0 through 9, and then two tilde characters -- this is now officially the 'end-of-entry' designation used based on the whole text file of entries, from top to bottom, however long or short.
  • 1
  • 3
  • 4
  • 5
  • 6
  • 7

@FiveofSwords Edwards' critique does not con[…]

Russia-Ukraine War 2022

70% of Americans view Ukraine as an ally or frien[…]

World War II Day by Day

April 19, Friday Allied troops land on Norway co[…]

My prediction of 100-200K dead is still on track. […]