79351743

Date: 2025-01-13 09:47:08
Score: 0.5
Natty:
Report link

Not a 'deepthroat' programmer at all here, but, couldn't sth like this also work?:

MYPATH="/could/you/please/let/me/keep/the/last/word/ofthis/line"

MYPATHLAST=$(echo "${MYPATH}" | sed -r "s/^(.*)([/])(.*)$/\3/")

echo "${MYPATHLAST}"

Maybe a bit extensive, this, and maybe out of context, but, often useful, sed. It literally takes any last word/part at the end of the given line '(.*)', referenced by group-id 3.

My 'context' is a bash script with zenity '--file-selection --directory' of which the output goes to this rsync:

rsync -rauW --delete --inplace --no-compress --info=progress2 ${EXCL} --mkpath ${SOURCE}/ ${DESTINATION}

(Nevermind the (unquoted) EXCL var, it references possible exludes also rendered through zenity.)

The problem is that '--mkpath' does create a dir by means of a bash script without zenity but not bmo a bash script with zenity --file-selection. You would have to type the new dir at destination from zenity --file-selection, if it doesn't exist. If rsync would create the new dir (the last word of the path-line), I could just select one destination dir upwards with zenity --file-selection to create the new dir with the same name as source dir within it.

So I'm looking for a way to first create the dir with the same name at destination (mkdir -p probably) and then run rsync on it.

Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: suahuab