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 7498743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:35:01+00:00 2026-05-29T19:35:01+00:00

So I want to automate a manual task using shell scripting, but I’m a

  • 0

So I want to automate a manual task using shell scripting, but I’m a little lost as to how to parse the output of a few commands. I would be able to this in other languages without a problem, so I’ll just explain what I’m going for in psuedo code and provide an example of the cmd output I’m trying to parse.

Example of output:

Chg 2167467 on 2012/02/13 by user1234@filename ‘description of submission’

What I need to parse out is ‘2167467’. So what I want to do is split on spaces and take element 1 to use in another command. The output of my next command looks like this:

Change 2167463 by user1234@filename on 2012/02/13 18:10:15

   description of submission

Affected files …

… //filepath/dir1/dir2/dir3/filename#2298 edit

I need to parse out ‘//filepath/dir1/dir2/dir3/filename#2298’ and use that in another command. Again, what I would do is remove the blank lines from the output, grab the 4th line, and split on space. From there I would grab the 1st element from the split and use it in my next command.

How can I do this in shell scripting? Examples or a point to some tutorials would be great.

  • 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-29T19:35:02+00:00Added an answer on May 29, 2026 at 7:35 pm

    Its not clear if you want to use the result from the first command for processing the 2nd command. If that is true, then

    targString=$( cmd1 | awk '{print $2}')
    command2 | sed -n "/${targString}/{n;n;n;s@.*[/][/]@//@;p;}"
    

    Your example data has 2 different Chg values in it, (2167467, 2167463), so if you just want to process this output in 2 different ways, its even simpler

    cmd1 | awk '{print $2}'
    cmd2 | sed -n '/Change/{n;n;n;s@.*[/][/]@//@;p;}'
    

    I hope this helps.

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

Sidebar

Related Questions

I want to automate a Windows 2000+ server reboot process using Task Scheduler or
I want to automate some GUI tasks using Selenium. And integrate this task in
I want to automate Excel using Perl to do the following task(s): For a
I want to Automate the build process of my company. We are Using.Net platform
I am using SourceForge for some Open Source projects and I want to automate
I want to automate interaction with a webpage. I've been using pycurl up til
i want to automate page using web browser automation. In the there is only
I want to automate testing of WCF Web Services(over TCP) using QTP's WebServices Add-In.
I am not a very good coder. But I really want to automate something
The problem is following: I want to automate the way my emacs starts. It

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.