WebHosting

Thursday, December 21, 2023

Display both head and tail of a file or a ls command output or anyother command

Following Commands will basically show head and tail of a command or a file at once, basically it will sho the start and end of a file or a command.

Combining head and tail using cat

    cat filename | head && echo "..." && cat filename | tail

Using sed command to display both head and tail:

    sed -n -e '1,10p' -e '$p' filename

To view both the head and tail of the output from an ls command, you can combine head and tail commands together with a pipe (|) to display both at the same time.

    ls -l | { head; echo "..."; tail; }

    ls -l > temp_file && { head temp_file; echo "..."; tail temp_file; } && rm temp_file


No comments:

Post a Comment

Thank you for Commenting Will reply soon ......

Featured Posts

เค•िเคธเค•े เคนिเคธ्เคธे เคฎें เคฎें เคฏे เคงเคฐเคคी

เคšिเคก़िเคฏों เค•ा เค˜เคฐ เคœเคฒ เคฐเคนा เคนै  เค‡ंเคธाเคจ เค–ुเคถ เคนै เค•ि เคฏे เค†เค— เคฆूเคฐ เคนै เค…เคญी เค•เคญी เคคो เค†เคเค—ी เค˜เคฐ เคคเค•  เคคेเคฐा เคญी เค˜เคฐ เคœเคฒेเค—ा เค•เคญी เคฌेเคœुเคฌाเคจ เคนै เค•ुเค› เคฌोเคฒเคคे เคจเคนीं เคนै เคฆिเคฒ เคฎें เคฆुเค– ...