Is there a way to simulate the *nix tail command on the Windows command line? I have a file and I want a way to snip off the first n lines of text. For example:
more /e filename.txt P n
where n = the number of rows to display. Works fast and is exactly like head
command.
set /p line= < file.csv
echo %line%
it will return first line of your file in cmd Windows in variable %line%.
When using more +n that Matt already mentioned, to avoid pauses in long files, try this:
more +1 myfile.txt > con
When you redirect the output from more, it doesn't pause - and here you redirect to the console. You can similarly redirect to some other file like this w/o the pauses of more if that's your desired end result. Use > to redirect to file and overwrite it if it already exists, or >> to append to an existing file. (Can use either to redirect to con.)
If you want the head command, one easy way to get it is to install Cygwin. Then you'll have all the UNIX tools at your disposal.
If that isn't a good solution, then you can try using findstr and do a search for the end-of-line indicator.
findstr on MSDN: http://technet.microsoft.com/en-us/library/bb490907.aspx
I have not tried extracting a range, but I was able to get a line using the following DOS command:
find /N " " *.log|find "[6]"
Since most files contain spaces, this command pulls every line from all LOG files and basically numbers them starting from 1 for each file. The numbered results are then piped into the second FIND
command which looks for the line tagged as number 6.
There's a free head
utility on this page that you can use. I haven't tried it yet.