Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:56:14+00:00 2026-05-16T14:56:14+00:00

I know, I know, I should use a modern shell… Anyway, so here is

  • 0

I know, I know, I should use a modern shell… Anyway, so here is the alias:

  alias p4client echo `p4 info | perl -ne 's/Client name: (.*)$/print $1/e'` 

I also know there is probably a better way to get the p4 client name. This is just an example. So, can anyone tell me a nice and clean way to get this to evaluate this when I invoke the alias rather than evaluating when the alias is created?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:56:14+00:00Added an answer on May 16, 2026 at 2:56 pm

    The only trick is backslash escaping the single quotes and surrounding everything else with single quotes:

    alias p4client 'echo `p4 info | perl -ne '\''s/Client name: (.*)$/print $1/e'\''`'
    

    Though the perl can be simplified:

    alias p4client 'echo `p4 info | perl -ne '\''print /Client name: (.*)/'\''`'
    

    and the echo and “ are saying capture the output these commands print and print it; just print the output instead (only having perl include the newline instead of stripping it from the p4 output only to have echo re-add it):

    alias p4client 'p4 info | perl -ne '\''print /Client name: (.*)/s'\'
    

    though now there’s nothing double-quote-unfriendly left in there, so:

    alias p4client "p4 info | perl -ne 'print /Client name: (.*)/s'"
    

    There’s nothing different here from how you would do it in bash except not having an = after p4client.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know you should use POST whenever data will be modified on a public
I know you should use a StringBuilder when concatenating strings but I was just
I need to know what should I use to store the property? I'm still
I don't know which title I should use for this question. I have a
I don't know how to use Quartz.dll in ASP.NET. Where should we write the
Ok, so I know you should use prepared statements to avoid injection attacks as
I know we should use JSON when receiving remote autocomplete suggestions, but I'm forced
I know I should use Services in Android to do stuff in the background
As we know, several modern applications (IE9, Firefox 4, Chrome, Paint.NET, etc.) use DwmExtendFrameIntoClientArea
I want to build a chat server but i don't know i should use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.