Improve this question. Community Bot 1 1 1 silver badge. Why do you say cat file head;tail doesn't? It seems to work for me. That also works for me. What system are you using? What version of Bash? Are there particular files it fails on? Do the files have fewer than 10 lines, between 10 and 20, or more than 20 lines? Just to add to the confusion: Mac OS X I see the first and last 10 lines with file redirection, but only the first 10 lines with the pipeline.
In both cases, wc -l is returning 0. Ubuntu I didn't know about this syntax, very cool. I was trying it out on Mac OS, with bash.
Xfce 4. Add a comment. Active Oldest Votes. OS X For OS X, you can look at the source code for head and the source code for tail to figure out some of what's going on. The -f option is ignored if no file operand is specified and standard input is a FIFO or a pipe. With kernel inotify support, output is triggered by file changes and is generally very prompt.
When using tail without inotify support, you can make it more responsive by using a sub-second sleep interval, e. That is, tail will attempt to reopen a file when it is removed. Should this fail, tail will keep trying until it becomes accessible again. When following a log file that is rotated, this is approximately the number of seconds between when tail prints the last pre-rotation lines and when it prints the lines that have accumulated in the new log file. This option is meaningful only when polling i.
Output the last num lines. Size multiplier suffixes are the same as with the -c option. When following by name or by descriptor, you may specify the process ID, pid , of the sole writer of all file arguments. Ask Question. Asked 7 years, 11 months ago. Active 2 years, 3 months ago. Viewed 13k times. Improve this question. The Unfun Cat. Add a comment.
Active Oldest Votes. Improve this answer. Damn, too fast Here's the relevant source code. Indeed, answer updated.
Note that not all tail implementation do it or do it properly. For instance busybox 1. Though seekable vs non-seekable inputs is definitely a valid point. Block People Spotify. Verizon Selling PS5. Windows 11 SE Explained. Windows 11 SE. Microsoft Default Browser Firefox. Google's New Pet Art. Robinhood Hack Find Downloaded Files on an iPhone. Use Your iPhone as a Webcam. Hide Private Photos on iPhone. Take Screenshot by Tapping Back of iPhone.
Should You Upgrade to Windows 11? Browse All Windows Articles. Copy and Paste Between Android and Windows. Protect Windows 10 From Internet Explorer. Mozilla Fights Double Standard. Connect to a Hidden Wi-Fi Network. Change the Size of the Touch Keyboard.
Check Bluetooth Device Battery Life. Reader Favorites Take Screenshot on Windows. Mount an ISO image in Windows. Boot Into Safe Mode. Disable Startup Programs in Windows. Where to Download Windows Legally. Find Your Lost Product Keys. The Best Tech Newsletter Anywhere Join , subscribers and get a daily digest of news, geek trivia, and our feature articles. How-To Geek is where you turn when you want experts to explain technology. Since we launched in , our articles have been read more than 1 billion times.
Want to know more?
0コメント