Skip to main content

All Questions

Tagged with
0 votes
1 answer
51 views

Bash - Log timestamp of the moment data was received on stdin, coming from a pipe

I have an application that outputs to stdout from time to time - random intervals, random durations of outputting before going silent again. Its output (binary data) is captured into a file. I want to ...
programings's user avatar
0 votes
1 answer
42 views

How to properly escape/quote the output so it's treated as an escaped input? [duplicate]

I've been trying to create a set of aliases or functions, that I can use in conjunction with file operating commands. The idea is to have 1, 2, 3 functions/aliases that will return latest, second-to-...
Mirek's user avatar
  • 397
3 votes
1 answer
202 views

Reading and Writing more than 4096 bytes to and from STDIN [closed]

I'm trying to implement a here document like the one used in bash (in C), but I noticed that I can't give it a line that's longer than 4096 bytes, I looked it up and It was because of the max size of ...
Anass Abidar's user avatar
0 votes
1 answer
35 views

Calling bash from python subprocess maintaining context, returning results and printing to screen

I have a function that sends a statement to bash. It prints the output in real time to the console and also returns the value. It works flawlessly and looks like this: def call_in_bash(statement): ...
Guillemdc's user avatar
4 votes
2 answers
583 views

Bash - Check if the standard input contains anything

I know this question has been asked several times but it seems ineffective in my case. [[ ! -t 0 ]] = Does standard input contains anything? This command: echo 'Hello world' | [[ ! -t 0 ]] echo $? ...
Mario Palumbo's user avatar
0 votes
1 answer
148 views

How to get Pipe and Here String in Python?

When calling a Python script via echo foobar | python myscript.py <<< test123 How can I get both strings (the "foobar" and "test123") in the Python script? When trying ...
gott18's user avatar
  • 3
1 vote
1 answer
59 views

Why grep ignores the first line of "python3 -m http.server" output?

For some reason grep will not print the first line of the output of the command: python3 -m http.server python3 -m http.server # prints: Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... ...
Marinos An's user avatar
  • 10.5k
4 votes
1 answer
264 views

Why does wc output different padding spaces depending on how stdin is connected?

See the following two commands with output: $ wc < myfile.txt 4 4 34 $ cat myfile.txt | wc 4 4 34 My understanding is that these two both connect the stdin of the wc process ...
cdjc's user avatar
  • 1,099
0 votes
0 answers
168 views

Bash read stdin line by line, and preserve null bytes

I'm currently using read to read from stdin line by line, but the input I'm reading contains null bytes, and storing the input in a variable removes them. Is there any way to get the data either as ...
LuisAFK's user avatar
  • 897
1 vote
1 answer
92 views

monitor pipe in bash

I have multiple pipe bash command, but let's simplify it to this command: echo "12 JAN 2023" | date -d - the output is: So 10. června 2023, 00:00:00 CEST I want to monitor, what is going ...
xerostomus's user avatar
0 votes
0 answers
77 views

How to keep two bash terminals session alive in python script?

I want to automate some process which will run some python scripts. I need to perform below steps Step 1: Open bash terminal (terminal_1) and run "Source script1.sh" => If this script ...
user2986042's user avatar
  • 1,156
0 votes
0 answers
36 views

Why does Bash eat the first letter from every second line of input when redirecting ffmpeg stderr to stdout? [duplicate]

When I run the following code, that is supposed to print out the filename and redirect ffmpeg's stderr information to stdout: #!/bin/bash while read -r filename; do echo $filename cmd_out=$(...
Tomasz's user avatar
  • 356
0 votes
0 answers
31 views

How does stdin work with the following commands

I am struggling to understand how does stdin work with these 3 commands: $ echo < file1.txt $ ls < file1.txt > file2.txt $ pwd < file1.txt > file2.txt The contents of the file file1....
Rodion Iskhakov's user avatar
2 votes
2 answers
234 views

Pass each line of stdout as stdin to a new invocation of a tool

I would like to pipe each line of stdout into stdin of a separate invocation of another tool - essentially mapping over lines, in bash on the command line. I know I can loop, but that's a bit verbose ...
Cornelius Roemer's user avatar
0 votes
1 answer
117 views

Why does the output of `paste` differ when using the standard input?

From man: paste writes to standard output lines consisting of sequentially corresponding lines of each given file, separated by a TAB character. Standard input is used for a file name of ‘-’ or if no ...
Mehdi Charife's user avatar

15 30 50 per page
1
2 3 4 5
24