Piping to provide a file as input to a C program

Aiyoyo

I have this set of .gz files and inside each of them is a single text file. This text file needs to be used in a C program. The following code solves this problem somehow where parameters 1 and 2 are integers which I'm receiving as arguments for the C program (argc, argv[]) in main().

gzip -dc xyz.txt.gz | ./program parameter1 parameter2

Can someone explain how the above code works in command line? How does the text file automatically get passed to the program? Do I need to write extra code in the C program to receive this text file?

Ignacio Vazquez-Abrams

The shell connects the stdout of one command directly to the stdin of the other command through a pipe(7). Neither program has to do anything out of the ordinary to take advantage of this.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Piping to provide a file as input to a C program

From Dev

Piping a data file with cat to a C++ program

From Dev

Provide output of C program as command line input Java program?

From Dev

Piping input from a file to a command in windows cmd

From Dev

C Program file-io user input

From Dev

File input from terminal C program

From Dev

C Program Structures Using File Input And Output

From Dev

C Program file-io user input

From Dev

File input from terminal C program

From Dev

C++, how to provide the input filename from the command line, without hardcoding it in the program?

From Dev

Piping in C: tee command produces empty file

From Dev

Making a bash script to accept input from file OR piping output

From Dev

realloc fails to expand char array when piping input from a file

From Dev

Bash script to sort input file before piping to while loop

From Dev

C++: Linux code does not work on Windows - piping data to program

From Dev

Continuous piping in bash program

From Dev

Continuous piping in bash program

From Dev

provide mp4 file as camera input

From Dev

(Unix/Linux) How would I execute a C program from another C program that requires an input file?

From Dev

Powershell input piping issue

From Dev

c program is not waiting for input

From Dev

Bad file descriptor error when implementing piping in C

From Dev

terminal: program input from file

From Dev

terminal: program input from file

From Dev

Make a program work with input and a file

From Dev

Provide hex value as an input to gets in C

From Dev

piping strings from program output

From Dev

Piping output from a segfaulting program

From Dev

Piping an interactive session to a file

Related Related

HotTag

Archive