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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:38:58+00:00 2026-06-15T22:38:58+00:00

I run the following in the command line: prog1 | prog2 The output (say,

  • 0

I run the following in the command line:

prog1 | prog2

The output (say, X) of above is a 4-digit hex number, e.g. FA34.
prog1 is a java program which reads data every 100ms on the serial. prog2 is the cut command which cuts out a portion I need. This works fine and I can see the desired value every 100ms on the standard out.

What I want:

prog1 | prog2 | <convert X to decimal> | <multiply by 2>

How to do this, using pipes or not, in the command line in one-go?

Note: I wrote a bash script to convert X to decimal and multiply by 2. But I couldn’t direct X into my script as an argument.

  • 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-06-15T22:39:00+00:00Added an answer on June 15, 2026 at 10:39 pm

    Here’s a funny possibility:

    { echo "iscale=16"; prog1 | prog2; } | sed 's/$/*2/' | bc
    

    This echos iscale=16 first (to tell bc to consider user’s input in radix 16). Then sed appends *2 to each line and all this goes through bc for the conversion to decimal and multiplication by 2.

    There’s a limitation: your program prog2 must output all the hexadecimal numbers in upper case (e.g., FA34 not fa34). If this is a limitation, use:

    { echo "iscale=16"; prog1 | prog2; } | sed 's/\(.*\)/\U\1*2/g' | bc
    

    instead.

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

Sidebar

Related Questions

I run a Java program with the following command line (Edit: in NetBeans 6.8
I have a setup.exe project that I run with the following command-line arguments to
I run the following code from command line: public class MemoryTest { public static
I want to run the following command from a C program to read the
I run the following command from the Windows command line to backup my database:
I'm able to run the following curl command (at the command line) successfully: curl
I have created following command line to run cron job after every 2minutes 2
In command line I have run the following command: C:> set _NT_SYMBOL_PATH=srv c:\symbols http://msdl.microsoft.com/download/symbols
When I run the following command from command line, I can run 7-zip as
What happens if I run following command : mvn clean install sonar:sonar -Dmaven.test.skip=true I

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.