Vim opens file even if the user does bot have write permission to the file. But after revision, how to write file content with sudo in Vim if Vim reports no permission to write the file. Use this command inside of vim to write to the file with sudo: :w !sudo tee % Here, !
Read more
Tag: tee
How to synchronize Google Drive and Google Docs files in Ubuntu/Debian/Mint Linux using Insync
Posted onGoogle Drive is a nice cloud storage service. It provides a suite of nice online document spreadsheet and slide editors Google Docs, Google Sheets and Google Slides. The collaborative editing and full history tracking features of Google Docs are excellent. Google Drive gives 16GB free storage which is pretty much larger compared to other free
Read more
How to make tee catch the stderr only in Linux?
Posted onI would like to make tee catch the stderr and log it into a file. A brute force method by let tee listen on both stderr and stdout is okay like cmd 2>&1 | tee -a log But how to make tee catch the stderr only? You can make use of “process substitution” (>(…)) to
Read more
How to redirect anything written on a file to another file in linux?
Posted onSuppose we have two files, a.txt and b.txt . If we write anything in a.txt & b.txt, it should be redirected to c.txt. tee may help for this purpose. tee: duplicate standard input You may try a command like this: echo “hello” | tee -a a.txt >>b.txt Both a.txt and b.txt will contain the “hello”.
Read more
How to redirect STDOUT of sudo command on Linux and write to file as root?
Posted onA try like the following command failed $ sudo echo “echo hello” > /usr/local/bin/hello with an message bash: /usr/local/bin/hello: Permission denied It seems the writing to the file is executed under the non-root user. How to redirect STDOUT of sudo command on Linux and write the content to the file (/usr/local/bin/hello here) as root? You
Read more