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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:26:38+00:00 2026-05-21T11:26:38+00:00

Hello:) I need someone to translate this little bash script to C because now

  • 0

Hello:)
I need someone to translate this little bash script to C because now it consumes way to much CPU and so that i (and other people searching this on google) can learn walking with C! This will be most effective to learn and im planing to do a lot with C but yet iam a programmer of script languages only and know very basic java….

*BASH SCRIPT TO TRANSLASTE TO C*
a1=$1
a2=`expr $a1 + 1`
a3=`expr $a1 + 2`
a4=`expr $a1 + 3`
a5=`expr $a1 + 4`
Limit=`expr $a1  +  99999999999`
while [ $a1 -le $Limit ]
do
echo $a1,$a2,$a3,$a4,$a5 | sed 's/9,/9abc/g' >> List$1
a1=`expr $a1  +  500`  
a2=`expr $a2  +  500`
a3=`expr $a3  +  500`
a4=`expr $a4  +  500`
a5=`expr $a5  +  500`
done

..Thus if i knew the following things in C this would be all for now.

  1. handleing the variables
  2. euivalent for >> adding to file but perferably with a cache to
    reduce disk io!
  3. something euivalent to $1 – allowing the user to set a variable
    when running the C programm.
  4. REGEX in C
  5. euivalent to | pipe in C
  6. Or how to execute a bash command within a C programm since it
    cant get much faster than grep,sed anyways…

Thanks a lot to everyone reading this

  • 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-21T11:26:39+00:00Added an answer on May 21, 2026 at 11:26 am

    Something like this:

    #ifdef __cplusplus 
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
    #else
        #include <stdio.h>
        #include <stdlib.h>
        #include <string.h>
    #endif
    
    char * stringReplace(char *string, char *search, char *replace) 
    {
        char *tempString, *searchStart;
        int len=0;
    
    
        // preuefe ob Such-String vorhanden ist
        searchStart = strstr(string, search);
        if(searchStart == NULL) {
            return string;
        }
    
        // Speicher reservieren
        tempString = (char*) malloc(strlen(string) * sizeof(char));
        if(tempString == NULL) {
            return NULL;
        }
    
        // temporaere Kopie anlegen
        strcpy(tempString, string);
    
        // ersten Abschnitt in String setzen
        len = searchStart - string;
        string[len] = '\0';
    
        // zweiten Abschnitt anhaengen
        strcat(string, replace);
    
        // dritten Abschnitt anhaengen
        len += strlen(search);
        strcat(string, (char*)tempString+len);
    
        // Speicher freigeben
        free(tempString);
    
        return string;
    }
    
    
    
    
    int main(int argc, char* argv[])
    {
        int i;
        for(i = 0; i < argc; ++i)
            printf("argv[%d]: %s\n", i, argv[i]);
    
        char string [256];
        int a1 = atoi((const char*) gets(string));
        int a2= a1 +1;
        int a3 = a1 + 2;
        int a4 = a1 + 3;
        int a5 = a1 + 4;
    
        int limit = a1 + 99999999999;
    
        while(a1 <= limit)
        {
    
    
            char command[1000];
    
            sprintf(command, "%d,%d,%d,%d,%d", a1, a2, a3, a4, a5);
    
            stringReplace(command, "9,", "9abc");
    
            FILE* pFile = fopen ("myfile.txt","wa");
            fprintf (pFile, "%s\n", command);
            fclose (pFile);
    
    
            /*
            sprintf(command, "echo \"%d,%d,%d,%d,%d\" | sed 's/9,/9abc/g' >> List%s", a1, a2, a3, a4, a5, string);
    
    
            FILE* pPipe  = popen(command, "r");
            char   psBuffer[128];
            while( !feof( pPipe ) )
            {
                if( fgets( psBuffer, 128, pPipe ) != NULL )
                    printf("%s\n", psBuffer );
            }
    
            pclose(pPipe);
            */
    
            a1 += 500;
            a2 += 500;
            a3 += 500;
            a4 += 500;
            a5 += 500;
        }
    
        return EXIT_SUCCESS;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling with this for a while now so hopefully someone can help
Hello is it possible if someone could tell me the easiest way to create
hello I'm new in java programming, and i need someone explaining me these lines
Hello pls could someone help... I've tried everything to get this to work in
Hello This is a complex question and I hope someone will be so nice
Hello I have an unsigned char * that looks (after printf) like this (it's
Hello I hope someone can help me. I need to know how to write
<?php $to = someone@example.com; $subject = Test mail; $message = Hello! This is a
Hello I need to have multiple language support of my django admin application.I can
Hello friends i need a book/ tutorials for rails without using scoffold. All the

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.