Tag Info

New answers tagged

1

simulation.py: (output 10 lines every second) #!/usr/bin/env python import time i=0 while True: print("{} what up {}".format(i,i%10)) if i%10==9: time.sleep(1) i+=1 In one terminal: $ stdbuf -oL python simulation.py >> log.txt In another one: $ tail -f log.txt #10 new lines every second


4

This is a feature of ATT ksh93 that was added in bash 2.04. None of the other common shells have it, in particular you won't find it in any of the dash variants, in pdksh or mksh (as of July 2015), in any of the BusyBox or Android variants, or in zsh¹ or fish. Bash can be compiled without this feature (see --enable-net-redirections), so it may be absent from ...


-2

cmd tty tty returns the name of the terminal connected to stdout.


3

If your shell supports them, the simplest way of doing such manipulations would be to use process substitution: <(…) and >(…). This works in bash, zsh and ksh and possibly other shells. For example: $ sort <(printf "b\nc\na\n") a b c $ ls foo $ cp <(find . -name foo) bar $ ls bar foo However, this won't help in the example you state since ...


-3

Or use a command substitution; this command is intrinsically redundant, but just to showcase the method: cat "$(<<< "files" sed 's/s//')" will cat a file named file in your current working directory.


1

you can try tac /DIRECTORY/TO/FILE.csv | sed -e 's/o,632/o,101/g' -e 's/o,938/o,103/g' -e 's/o,510/o,112/g' -e 's/ombo,713/ombo,102/g' | while read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 do if [ "$f7" = "EnHr" ] && [ "$f10" -gt 0 ] && [ "$f4" = "$m_class" ] && [ "$f5" = "$m_id" ] then ...


11

From the pdftotext man page: If text-file is ´-', the text is sent to stdout. So in this case all you need is: pdftotext "C BY BRIAN W KERNIGHAN & DENNIS M RITCHIE.pdf" - Or if you want to pipe this to STDIN of another program: pdftotext "C BY BRIAN W KERNIGHAN & DENNIS M RITCHIE.pdf" - | another_prog Using - as substitute for a ...


1

<<< in bash is a here string. You passed your script string itself tac /DIRECTORY/TO/FILE.csv ... to while's stdin. You might have wanted to use process substitution: while read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 do ... done < <(tac /DIRECTORY/TO/FILE.csv ...)


13

If the said program supports to write to any file descriptor even if it can't seek, you can use /dev/stdout as output file which is a symlink to /proc/self/fd/1 on my system. File descriptor 1 is stdout.


5

&>word is: semantically equivalent to >word 2>&1 It's not the same as 2>&1 alone. Just as for redirecting output, the word (destination) part is required. 2>&1 is actually using a different operator, and it requires the destination word too (it's "1" here). Redirections are applied in order, and it's permitted to ...


1

You don't get to select lines. Only whole streams (stdin, stdout, stderr (more generally, any open file descriptors, not just these standard ones)) can be redirected. You can simulate what you want by piping into commands that will sort out the output lines for you. $ echo -e "hello\nworld" | #write hello and world; one per line tee >(grep hello ...


0

If it is a specific line/command in the script, you can send its output to /dev/null inside the script. The command inside the script will look like: command > /dev/null This will result in the output getting lost. If you want it to appear on the console, you can send it to stderr as command 2> `tty` 1>&2


3

You can use a tool like sed to alter the output of script.sh, including "deleting" lines from the stream. If you want to delete a line by line number you could do /a/b/c/script.sh | sed -e '5d' >> abc.log which in this example will remove the 5th line from the output. Replace 5 with any line number. /a/b/c/script.sh | sed -e '/<regex>/d' ...


3

/a/b/c/script.sh >> abc.log This command means that any output that script.sh writes to the standard output stream will be appended to abc.log If you wish to exclude a line, or multiple lines that match a similar pattern you can use grep -v to accomplish this: /a/b/c/script.sh | grep -v '<line-to-ignore>' >> abc.log or to match a ...


1

GAH! I just figured it out... It looks like the redirection gets reset when you invoke another function. But that's not it. The real problem is much more dumb: IFS='' read -r n1 CHAR There's a dash missing! IFS='' read -r -n1 CHAR [facepalm]


1

A good alternative is psgrep -d , lsof -p $(pgrep -d , postgres) -d Specifies the delimeter.


1

gpg --batch would work for that purpose.


6

The pipe will immediately get closed on nc's end. When omxplayer dies nc will receive SIGPIPE on writing to the fifo, not to the pipe. It might be better to just run nc in the background so that you could keep control over omxplayer via stdin. mkfifo tcp.stream nc -l -p 1234 > tcp.stream & omxplayer --live tcp.stream However, using | instead of ...



Top 50 recent answers are included