Newer versions of bash also support a fancier syntaxįor redirecting both standard output and standardĮrror to the same file: the &> notation ls docs &> output. Or we could instead use 2>&1 which is a fancy syntaxįor saying "redirect standard error to the same Standard error to the same file, we could do ls docs > output.txt 2> output.txt If we wanted to redirect both standard output and cat bees.txt ants.txt > insects.txt 2> error.txt Insects.txt, and redirecting standard error to a file called error.txt. We can redirect multiple streams at once! In this example, we areĬoncatenating two files, redirecting standard output to a file called If you dont know grep, filename is a text file where each line has a. To specify 1> to redirect standard output: ( date 1> now.txt = date > now.txt) all together bin/sh The other native method PowerShell offers is the Select-String cmdlet. The > operator actually defaults to using 1 as theįile descriptor number, which is why we don't need In both cases, you see the entire log buth with highlighted search term like this: The -f switch could be omitted if no live grep is wanted. If the container logs to stderr, you can pipe them as Edoardo already wrote for a simple grep: docker logs -f 2>&1 | grep -line-buffered -i -E -color "select count\(\*\)|$"
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |