I have this C function that I am using to output any amount of integer that is input.
/*
This program will be called function.c
*/
#include <stdio.h>
int main (void) {
int num;
while(scanf("%d",&num)==1) {
printf("You entered: %d\n",num);
}
return 0;
}
In my shell the function works like this as expected with the pipe command
$echo "1 7 3 " | ./function
Output:
You entered: 1
You entered: 7
You entered: 3
Now what I'm trying to do is use the sed command on a csv file and pipe the output into my function.
Here is my CSV file
$cat file.csv
Output:
2,2,3,3,8
Using the sed command I remove the commas
$sed 's/,/ /g' file.csv
Output:
2 2 3 3 8
Now the issue I have is when I try to use the output of the sed command to pipe the numbers into my function:
$sed 's/,/ /g' file.csv | ./function
I get no output. I don't know if there is a syntax error, but I believe I should be able to do this with a csv file.
Copyright License:
Author:「jamxy」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/73759882/how-to-pipe-the-output-of-a-sed-command-into-a-function-in-unix