redirect,zsh,xargs , xargs: exec command with prompt

xargs: exec command with prompt


Tag: redirect,zsh,xargs

I'm trying to do the following with xargs

pacman -Q | grep xf86-video | awk '{print $1}' | xargs pacman -R to remove all xf86-video-* driver on my machine. To make the question more clear, here is the output of pacman -Q | grep xf86-video | awk '{print $1}':


when I redirect the result to xargs, the output looks like this:

xargs result

The point is, the command which xargs is about to execute need user to do some additional input(as you can see it needs a Yes/No), but xargs automatically add a unknown symbol #, and exit, which causes my purpose UNACHIEVED.

WHY xargs would do this or, what can I do to use xargs for command with prompt?


You can use

xargs -a <(pacman -Q | awk '/xf86-video/{print $1}') pacman -R


Without further arguments xargs does not work with interactive (command line) applications.

The reason for that is, that by defaultxargs gets its input from stdin but interactive applications also expect input from stdin. To prevent the applications from grabbing input that is intended for xargs, xargs redirects stdin from /dev/null for the applications it runs. This leads to the application just receiving an EOF. (Running just pacman -R SOMEPACKAGE and pressing Ctrl+D has the same effect).

To get xargs to work with interactive commands you have to use the --arg-file=FILE argument (short -a FILE). This tells xargs to get the arguments from FILE. This also leaves stdin unchanged.

So you could either put your package list into a temporary file

pacman -Q | awk '/xf86-video/{print $1}' > /tmp/packagelist
xargs -a /tmp/packagelist pacman -R
rm /tmp/packagelist

or you can use zsh's process substitution mechanism <(list). When executing a line with <(list), <(list) is replaced by a filename from where the output of list can be read.

xargs -a <(pacman -Q | awk '/xf86-video/{print $1}') pacman -R

The single # you get is not from xargs but from zsh itself. If the shell options PROMPT_CR and PROMPT_SP are set (which both are by default) zsh tries to preserve partial lines, that is lines that did not end with a newline. To signify that such a line has been preserved zsh prints an inverse+bold character at the end of that line, by default % for normal users and # for root.


Should my $PATH be returning anything RVM related?

I am running the command echo $PATH which is returning the following information containing RVM /Users/RAI/.rvm/gems/ruby-2.1.1/bin:/Users/RAI/.rvm/gems/[email protected]/bin:/Users/RAI/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/RAI/.rvm/bin Should this command only return the following? /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin Note that I am currently using on My Zsh...

mod_rewrite - force redirecting to rewritten URL

I have following URL [1]: which i want to redirect to [2] I am using following code in my .htaccess: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^search/(.*)$ /?search=$1 [L] Code above works kind of fine since server understands both URLs:...

Grails: Carry forward params on hyperlink is clicked

How to carry forward the parameters when hyperlink is clicked? Here is my gsp code: <g:link class="grid_link" controller="user" action="delete" id="${}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure, want to delete?')}');">Delete</g:link> Here is my controller code: def delete() { try { def userInstance = User.get( //deleting the user //successful. redirect(action: "list",...

htaccess redirect to subdomain based on query string

I searched for similar questions but none of them was applicable to my situation. What I need to do is redirect from old url's that have specific query string: option=com_virtuemart to a subdomain : Tried bunch of rules and conds but haven't achieved right redirection. It was always redirecting...

How can I redirect all visitors to a subdirectory but still have access to the root directory for development

I'm about to start building a site and I've set up an "Under Construction" site at I'd like to work directly on the root directory during development so that I don't have to move all files from a development subdirectory to the root directory, so I'd like to redirect...

An illustration of AWS hosted zones and buckets

After more than a few experiments with hosted zones and buckets, it seems I'm getting failures due to unexpired caches even though I may well have set up everything correctly. Before proceeding, I'd like to summarize using two sketches the lengthy (and frankly, tedious) AWS documentation, and ask whether these...

Redirect stdout using exec in subscript

I have one main script which is started as an service. I can't modify this main script, because it is often updated. This main script starts a program, which echo any log to stdout. So i can't see any log of this program. But this main script calls at the...

Redirect without changing Url htaccess

I'm wondering if this is possible - I have projects structured like: points to MyFolder on server. In MyFolder i have 3 App Folders eg MyFolder/App1, MyFolder/App2.. Each of these are 3 different web applications. Url of domain is Is it possible, that, when url user go to...

Cannot get wp_redirect to work

I'm trying to send an email using wp_mail and then, if mail is sent successfully, redirect user to another page (or, if not successful, to an error page). My code is shown below. The email is actually sent, so wp_mail is working, but I cannot get the redirect to work....

Links do not redirect to Jquery Tabs

I have 4 links as <li><a class="open-tab" href="#sirkethesaptab">Şirket Hesabı</a></li> <li><a class="open-tab" href="#musterihesaptab">Müşteri Hesabı</a></li> <li><a class="open-tab" href="#odemetab">Ödemeler</a></li> <li><a class="open-tab" href="#harcamatab">Harcamalar</a></li> <li><a class="open-tab" href="#personeltab">Personel</a></li> And i have a Jquery tab <div class="col-sm-9...

Force WWW when URL contains path using .htaccess

I'm having a problem with my URL and my sessions. I wish to have ALL website pages be forced to use www. As it looks like now, the website looks like this: into into into into (this is what's wrong) This is...

PHP redirect page works only in localhost

I haven't found any solutions for my problem so I decided to ask. I would like to redirect my php script page after submitting a form, so I use header at the end of my codes! Interestingly, when I test it in my localhost, it works and redirects the page...

.htaccess allow image to display directly

I have many files including images, php& js scripts and subfolders. I need to redirect to index.php for any uri using .htaccess. for example: should be redirect to index.php But images should not be redirected to index.php. Instead it should be printed directly in browser. For example: should...

oh-my-zsh error after upgrade: ~/.oh-my-zsh/lib/misc.zsh:3: parse error near `then'

today I upgrade my oh-my-zsh and then start this error: ~/.oh-my-zsh/lib/misc.zsh:3: parse error near `then' Inside this file there is this shell loop... ## Load smart urls if available for d in $fpath; do if [[ -e "$url/d-quote-magic"]]; then autoload -U url-quote-magic zle -N self-insert url-quote-magic fi done I think...

Redirect specific Url variables

My site used to generate URLs like this: /data.php?s=1432862823&type=basic I have modified the program so the new URLs generated are: /d.php?s=1432862823&t=basic Since some people have bookmarked the old URLs I want to write a Rewrite rule that will get them to the new url. I've not this so far: RewriteEngine...

How to redirect and then stop in node.js

I am trying to stop users accessing certain pages whilst logged in and not logged in with node.js. So far I have this idea: exports.blockIfLoggedIn = function (req, res) { if (req.isAuthenticated()) { //passport req.flash('error', 'Sorry but you can\'t access this page'); res.redirect('/'); } }; MA.f.auth.blockIfLoggedIn(req, res, next); res.render('users/login', {...

Get Parameter from URL using PHP

I have a url: I am currently successfully passing the postback parameter using the PHP below. However, I can not figure out how to also pass the city parameter. <?php session_start(); if(isset($_SESSION['postback'])) { if($_GET['postback'] == "") { header ("Location: qualify-step2.php?postback=".$_SESSION['postback']); } } ?> Can someone please help me edit...

Htaccess regex: exclude REQUEST_URI

I really tried everything, the tool htaccess tester says that it's ok, but it's not really working. I want to redirect a subdomain to the main domain only if the REQUEST_URI doesn't start with 3 specific strings. I tried without success with: RewriteCond %{HTTP_HOST} ^$ [NC] RewriteCond %{REQUEST_URI} !(aaa|bbb|ccc) RewriteCond...

Redirect only non-existing sub-directories to another domain using wildcard

In Apache, how do i redirect all non-existing directories for one domain (E.g.*.*) to another (e.g.*.*)? I don't want the redirect to occur if the directory exists on the first server ( Just for non-existing directories. Example: <--- Exists on the server, so it should NOT redirect....

Redirect to edit page automatically if record exists

I want to create a new record if it not exist. Otherwise, redirect to edit page automatically. In case the record exists (e.g: @sale is not nil). However, I got error message: app/views/sales/_form.html.erb where line #1 raised: First argument in form cannot contain nil or be empty Please show place...

Redirect based on operating system

I'm new here and I apologize if this question is basic/stupid. I am not too familiar with coding, so please excuse my ignorance/glaring errors. I have tried to put this together using code snippets found online and luckily I don't have to code too much for this project. I am...

How do I redirect a URL with a parameter to a clean URL in htaccess?

I am attempting to 301 redirect several URLs with parameters at the end to clean URLs. For example I am trying to redirect: to Here is my code: RewriteCond %{QUERY_STRING} id=1234 RewriteRule ^news/news\.php$ /posts/vanity-url.php [L,R=301] I feel like I'm close with this code but it redirects me to:...

How to redirect user to another internal page?

After creating the record, the user would be redirected to an internal page. "redirect to home.html" I've tried, add the code under "Sucess" but had no success :( How to be redirected after register or log in? window.location.href = ""; With the above code only works after pressing F5 <script...

.htaccess - 301 redirect where the URL structures aren't identical

I've been looking around for the answer to this but haven't been able to solve it myself. What I'm trying to do is redirect a group of around 1500+ URLs from one format to another, where the only thing that's consistent between the two is a string of numbers at...

Tmux breaks zsh aliases

I have a file .aliases that I point to in my .zshrc file DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [ -f $DIR"/.aliases" ]; then . $DIR"/.aliases" fi This code is the same in my .bashrc file (in the process of switching over to zsh). The aliases...

Mod Rewrite Maintenance page that uses multiple URLs

I have a site the uses multiple URLs for a single application. Depending on the URL of the site you will get different content. I need to create a rewrite rule that redirects a user to a different page depending on what URL the user hits. For example: If a...

Apache htaccess redirect file

I want to redirect any request for file from my old website to the same file but with different url on my new website : -> I have tried this solution on .htaccess file: RewriteEngine On RewriteRule ^(aaa/bbb/ccc/)(.*)$$2 [R=301,L] but when I try with this url :...

Use JS to convert URL #fragment BEFORE it gets lost to 301 redirect?

In real trouble here. Our old website featured a gallery slider that used URL #fragments to position a jQuery slider on the right project. For instance, /work/interactive#777 brought you to the /work/interactive page--which shows one project at a time in a slider--and then animates the slider to project with the...

redirect after 5 seconds but only allow the page to be accessed by the refferer [SOLVED]

After 16 hours of constant trying and learning as i go along.. im no better off and become over frustrated! So im now in desperate need of help, Any advice or help would be greatly appreciated. I am trying to have page1.php redirect to page2.php after 5 seconds, However page2.php...

RewritePath doesn't change browser URL,redirect
Inside my Global.asax.cs I have the following simple code: void Application_BeginRequest(object sender, EventArgs e) { if (HttpContext.Current.Request.RawUrl.Contains("/oldControler/oldAction")) { HttpContext.Current.RewritePath("/newControler/newAction"); } } The above code causes redirection to "newControler/newAction" rendering the correct View, yet the URL that shows up in the browser is still "/oldControler/oldAction". In case it's of any help,...

Excluding certain pages from being redirected to https

I'm using the following rules on my WordPress website to: Redirect all http pages to https Redirect the careers page to http <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/careers$ [NC] RewriteRule ^(.*)$$1 [R,L] # Go to http if...

Open file in $EDITOR by default in zsh

In zsh, if you can open directories without specifying cd command, like this % pwd /home/user/test % ls integration shared unit % unit % pwd /home/user/test/unit This effectively saves writing 'cd' everytime you try to open a directory. However it's smart enough not to 'cd' into files. Would it be...

Make vim follow symlinks when opening files from command line

I'm a huge vim lover, but I can't find a way to get vim to follow symlinks when opening files. As an example, all the dotfiles in my home dirs are symlinked to within the .zprezto directory: .vimrc -> ~/.zprezto/runcoms/vimrc .zshrc -> ~/.zprezto/runcoms/zshrc I'm keeping my fork of .zprezto in...

Why redirect PHP get only white page?

I'm developing in PHP, and I need to change page for different type of user, so I do in this way: switch ($_SESSION['ruolo']) { case 0: header('Location: ./php/admin/homeAdmin.php'); exit(); break; case 1: header('Location: ./php/150ore/home150.php'); exit(); break; case 2: header('Location: ./php/150ore/home150.php'); exit(); break; default: break; } But I obtain only a...

PHP - Image Upload , move_uploaded_file not working?

I have coded a image upload script but when I click upload i get redirected to the upload page? Here is the code: $image1name = $_FILES['image1']['name']; $image1crntloc = $_FILES['image1']['tmp_name']; $image1ext = pathinfo($image1name, PATHINFO_EXTENSION); $image1size = $_FILES['image1']['size']; $allowedext = array("jpg","gif","png"); //check image 1 extension. if (!in_array($image1ext,$allowedext)) { echo "<script>alert(\"Image 1 has...

python requests with redirection

Trying to authenticate on site, noticed that there were a redirect to Found that there were 302 POST with plain credentials in data form. Copying headers from Chrome can reproduce that in cURL, but still can't reach in requests module. Warning: page is full of russian letters, registration...

Redirecting http to https

I'd like to redirect all of my http traffic to https, currently in my htaccess file I have the following redirecting my http traffic: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] </IfModule> This redirects all of my non-www to www. What is the best way to...

Javascript: OS-depending Redirects doesn't work for IOS

i've got a pretty simple Javascript for redirecting a specific URL to an app in Google-Play-Store/iOS-Store or show an URL for desktop users depending on the client's opersting system. For the ios case the redirect is not being executed, can anyone explain what the problem is? (alert before redirect is...

Timeout handle email php

I would like to redirect my user to a new page, but the current site continues to run a script that sends a threaded message 10 minutes later at a specified address. I tried something like this: Header('Location:'); sleep(100); do_the_email_sending_here(); But actually it doesn't worked,because the site waited for...

301 Redirect Regex Pattern - Sitecore Redirect module

I apologize if this seems like a rudimentary question, but I'm trying to setup a redirect pattern for the 301 module in Sitecore and am having a hard time with the proper pattern. I need to have the following path: converted to: Basically strip the numerical folders out....

Redirect to a homepage cakephp 3

I've followed the articles tutorial from cakephp 3 website and created the website Now there is add article, delete article and edit article actions. When I delete an article it redirect me to http://localhost:8888/test/articles/delete/14 Here is the delete code. public function delete($id) { $this->request->allowMethod(['post', 'delete']); $article = $this->Articles->get($id); if...

Why mozilla changes the characters when i use the .net mvc statement redirect?

I'm trying to redirect to an external website when everything is done, but firefox changes the http word on the url for a weird set of characters. This is my server side code: [HttpPost] public ActionResult Postular(INFO_BASE_POSTULACION_model pInfoPostulacion) { string rutMD5 = Request["rutMD5"]; int idRegion = Convert.ToInt32(Request["idRegion"]); int idInstrumento =...

C# mvc4 - direct URL to controller

I have an external URL that points directly to a function in my controller but when I click on it for the first time, instead of reaching the page, I get to the home page. However, on the second click (and the following ones), I can reach the desired page....

PHP - .htaccess and GET parameters

I am trying to create a simple redirect to another page on login script. Currently I am rewriting my URLS to the following format using .htaccess: RewriteRule ^login$ ?i=l [L] RewriteRule ^login([^/]*)$ ?i=l&=$1 The normal URL is therefore: - although I wish to be able to do the following:...

.htaccess | Too many redirects

I want to add a IP filter into my .htaccess file, but after I applied it, a too many redirects error will show. Content of .htaccess: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301] RewriteCond %{HTTPS} on RewriteCond %{REMOTE_ADDR}

Laravel 5 pagination with trailing slash redirect to 301

I'm using Laravel 5 and notice that the pagination is adding a trailing slash before the ?page=# and with that, it always redirect to a 301 page. will do a 301 redirect to This is causing my pagination using ajax to slow down because it is having 2...

How to redirect domain with www or without www

I am using the following rewrite rule to redirect domain that has or has not www. RewriteCond %{HTTP_HOST} !^www\.[NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] It works fine for any sub domain name like or But not adding https in case of or I tried...

Redirect /{POSTID}/{CATID}/{TITLE} to just /{POSTID}/

I need help with a rewrite / redirect rule to fix some duplicate content issues on my website. I have a URL structure that it causing a ton of duplicate content. The same page can be accessed with: /Static1/Static2/Static3/{POSTID}/{CATID}/{TITLE} /Static1/Static2/Static3/{POSTID}/{CATID}/ /Static1/Static2/Static3/{POSTID}/ So, there are 3 copies of every page. I...

Redirect 301 with wordpress articles from a domain to another

my client changed his wordpress website to a new domain. I tried with the htaccess to redirect 301 the articles dynamicaly but it's not working. The URL format of articles are : /%year%/%monthnum%/%day%/%postname%/ I put this in htaccess but not working : redirect 301 /([0-9]*)/([0-9]*)/([0-9]*)/(.*)/$1/$2/$3/$4/ Can you help me...

Naked Root Domain Hosting

The usual approach calls for pointing to But suppose that I would like not to redirect. In other words, I would like to set up a naked root domain, without setting up any sub-domains, not even I am using Route53 and S3. Presumably I would need just...