I need to get the very first line of the command line output not all line, For example if i give
C:\Temp> dir
I need display the Very first line only like,
11/15/2012 06:58 PM <DIR> .
How can i get this ?
Thanks in advance.
How do I print the first 5 lines of a file? To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file.
Adding #!/bin/bash as the first line of your script, tells the OS to invoke the specified shell to execute the commands that follow in the script.
When you want to go back, type cd - and you will be back where you started.
In computing, start is a command of the IBM OS/2, Microsoft Windows and ReactOS command-line interpreter cmd.exe (and some versions of COMMAND.COM) to start programs or batch files or to open files or directories using the default program.
One approach to get the first line of output for a given command is to execute the command in a FOR loop, then break out of the loop after the first line.
@ECHO OFF
SET COMMAND=dir
FOR /F "delims=" %%A IN ('%COMMAND%') DO (
SET TEMPVAR=%%A
GOTO :Print
)
:Print
ECHO %TEMPVAR%
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With