0

The output of the following command is:

$ rga --heading -l --context 3 --sort path -i -e "use cases?" -e "user stor(y|ies)" -e "Technical debt"

Stepanek G. - Software Project Secrets (The Expert's Voice in Project Management) - 2012.pdf Strategic Project Management Made Simple Solution Tools for Leaders and Teams (Terry Schmidt) (z-lib.org).pdf Succeeding with Agile Software Development Using Scrum.pdf Team Topologies Organizing Business and Technology Teams for Fast Flow (Matthew Skelton Manuel Pais [Skelton etc.) (z-lib.org).epub The Agile Samurai How Agile Masters Deliver Great Software (Jonathan Rasmusson) (z-lib.org).pdf The Art of Agile Development - James Shore & Shane Warden.pdf The Art of Lean Software Development a Practical and Incremental Approach (Curt Hibbs Steve Jewett Mike Sullivan) (z-lib.org).pdf The Art of Project Management - By Scott Berkun.pdf The Complete Software Project Manager Mastering Technology from Planning to Launch and Beyond by Anna P. Murray (z-lib.org).pdf The Enterprise and Scrum (Ken Schwaber) (z-lib.org).pdf The Fast Forward MBA in Project Management 3rd Edition (2008) (Portable Mba Series) (Eric Verzuh) (z-lib.org).pdf The Making of a Manager (Julie Zhuo) (z-lib.org).pdf The Manager’s Path A Guide for Tech Leaders Navigating Growth and Change (Camille Fournier) (z-lib.org).epub The PMI Guide to Business Analysis (Project Management Institute) (z-lib.org).epub The Phoenix Project.pdf The Rational Unified Process An Introduction (Philippe Kruchten) (z-lib.org).pdf The Scrum Field Guide Agile Advice for Your First Year and Beyond (Lacey Mitch.) (z-lib.org).pdf The Unicorn Project A Novel about Developers, Digital Disruption, and Thriving in the Age of Data by Gene Kim (z-lib.org).epub The rational unified process made easy a practitioners guide to the RUP (Per Kroll Philippe Kruchten) (z-lib.org).pdf Tim_Brizard-Broken_Agile-EN.pdf Visualizing Project Management - Models and Frameworks for Mastering Complex Systems by Kevin Forsberg, Hal Mooz, Howard Cotterman (z-lib.org).pdf essential-scrum-a-practical-guide-to-the-most-popular-agile-process.9780137043293.57714.pdf succeeding-with-agile-software-development-using-scrum.9780321579362.53099.pdf

I am trying to move these files to a separate directory.

The commands I tried is:

rga --heading -l --context 3 --sort path -i -e "use cases?" -e "user stor(y|ies)" -e "Technical debt" | xargs -I {} mv {} DEST

and

rga --heading -l --context 3 --sort path -i -e "use cases?" -e "user stor(y|ies)" -e "Technical debt" > files.txt
for file in $(cat files.txt); do mv "$file" DEST; done

I am getting xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option

and

rga --heading -l --context 3 --sort path -i -e "use cases?" -e "user stor(y|ies)" -e "Technical debt" | xargs -r0 mv -t DEST

and

for file in $(cat temp.adoc); do mv "$file" "DEST/$file"; done

It says mv: cannot stat '''Stepanek ...

Ahmad Ismail
  • 2,678

2 Answers2

3

With GNU xargs and mv and shell (bash), you'd do:

xargs -rd '\n' -a <(rga...) mv -t DEST/ --

Without -d (or -0 which is short for -d '\0'), xargs still understands ', " and \ as quoting operators.

Using xargs -a <(...) cmd (which needs a shell with ksh-style process substitution like zsh or bash, though other shells like rc, es or fish also have the feature with a different syntax) is better than using ... | xargs cmd in that it allows cmd to interact with stdin, and mv may prompt the user under some circumstances.

Using mv -t /DEST ... means we can pass several files to mv and not have to spawn one process and execute mv for each file.

2

All of these variations you've tried use cat file.txt. This ends up unrolling each filename, and is subject to splitting on $IFS - typically whitespace. For example, "The Phoenix Project.pdf" then becomes three words "The", "Phoenix", "Project.pdf". Obviously none of these exist as a file and therefore cannot be moved.

I'm not familiar with rga, but given your output this is how you could approach a solution:

rga … |
    while IFS= read -r file
    do
        mv -- "$file" DEST/
    done

Or if you can guarantee that each filename is on a line by itself,

rga … | tr '\n' '\0' | xargs -0r -n1 -I{} mv -- {} DEST/
Chris Davies
  • 116,213
  • 16
  • 160
  • 287