From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: ng0 Newsgroups: gmane.lisp.guile.user Subject: Re: How to pass something on to xargs rm? Date: Tue, 27 Dec 2016 12:42:13 +0000 Message-ID: <871swta6hm.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> References: <87d1gd7gji.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> <20161227120750.GA16030@jocasta.intra> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1482842582 13209 195.159.176.226 (27 Dec 2016 12:43:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 27 Dec 2016 12:43:02 +0000 (UTC) Cc: guile-user@gnu.org To: John Darrington Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Dec 27 13:42:57 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cLr5e-00022M-SM for guile-user@m.gmane.org; Tue, 27 Dec 2016 13:42:50 +0100 Original-Received: from localhost ([::1]:53831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLr5j-0002u1-NY for guile-user@m.gmane.org; Tue, 27 Dec 2016 07:42:55 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cLr5G-0002to-Rf for guile-user@gnu.org; Tue, 27 Dec 2016 07:42:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cLr5D-0007nC-Fu for guile-user@gnu.org; Tue, 27 Dec 2016 07:42:26 -0500 Original-Received: from aibo.runbox.com ([91.220.196.211]:59715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cLr5D-0007il-5r for guile-user@gnu.org; Tue, 27 Dec 2016 07:42:23 -0500 Original-Received: from [10.9.9.210] (helo=mailfront10.runbox.com) by bars.runbox.com with esmtp (Exim 4.71) (envelope-from ) id 1cLr58-00066E-I9; Tue, 27 Dec 2016 13:42:18 +0100 Original-Received: from [179.43.169.2] (helo=localhost) by mailfront10.runbox.com with esmtpsa (uid:892961 ) (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) id 1cLr4k-0007Pu-TD; Tue, 27 Dec 2016 13:41:55 +0100 In-Reply-To: <20161227120750.GA16030@jocasta.intra> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 91.220.196.211 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13064 Archived-At: John Darrington writes: > On Tue, Dec 27, 2016 at 11:33:21AM +0000, ng0 wrote: > Hi, > > I have some scripts and small applications I'm slowly moving over > to guile. > One of them features this[0] line at the end which passes results on > to xargs rm. I picked a start with just (system*) everything I > had before to learn about the behavior and outcome, and improve > from this point. > I know that "|" will not work, so what else could possibly work > (for starters, in the long run I'll generalize and extend what I > currently have) to execute this command which deletes every file > listed in the previous search? > > [0]: notmuch search --output=files tag:deleted | xargs -L 1 rm > > > I think you want something like: .... | xargs -I {} rm {} > > > J' I think I was a bit too verbose with my question. I meant to say: the part behind the "|", which originates from a 1:1 conversion of the bash based part, is ignored for obvious reasons. But what would be a quick way (until I've learned enough on this topic myself) to perform the deletion? I know that the original, "notmuch search --output=files tag:deleted | xargs -L 1 rm" works in the bash script, but for the .scm script, everything above (fetching mail, tagging mail) works and this part is ignored: (system* "notmuch" "search" "--output=files" "tag:deleted" "|" "xargs" "-L" "1" "rm") To give you an idea, this is (part of) the mailget.scm: ng0@wasp ~$ cat mailget #!/home/ng0/.guix-profile/bin/guile \ -s !# (let* ((home (getenv "HOME")) ;;(tor-on (system* "." "torsocks" "on")) ;;(tor-off (system* "." "torsocks" "off")) (nm-new (system* "notmuch" "new"))) (chdir (string-append home "/.getmail")) ;; tor-on ;;# find . -name '*.rc' | xargs -n1 -i basename {} .rc | xargs -P 2 -n1 -i getmail -r {}.rc ;; FIXME: *.rc not found here: ;; (system* "parallel" "getmail" "-q" "-r" "{}" ":::" "*.rc") (system* "getmail" "-r" "getmailrc_grrlz_2.rc") (system* "getmail" "-r" "getmailrc_runbox.rc") ;;tor-off nm-new (system* "notmuch" "tag" "-inbox" "+sometag" "--" "some subject") … ;; Of course I don't have literally somesubject sometag, I just will not expose what I tag and sort. … (system* "notmuch" "search" "--output=files" "tag:deleted" "|" "xargs" "-L" "1" "rm") (display "done") (newline)) If there is no obvious, quick solution based on what I currently do, I will gladly accept any small pointers to subjects I could read into and solve it later in a better version. I consider the current script just a small hack. One solution I can imagine is that I write some functions which will allow me to save the output of such a search into a list I can work with and execute the physical deletion on each element. > -- > Avoid eavesdropping. Send strong encrypted email. > PGP Public key ID: 1024D/2DE827B3 > fingerprint = 8797 A26D 0854 2EAB 0285 A290 8A67 719C 2DE8 27B3 > See http://sks-keyservers.net or any PGP keyserver for public key. > -- ♥Ⓐ ng0 PGP keys and more: https://n0is.noblogs.org/ http://ng0.chaosnet.org