You are on page 1of 1

Top 5 way to display content of files using nontraditional method.

Let create a file called test100.txt.

1. Our first command is non tradition command called cut command.


Linux command: cut -c 1- test100.txt
Note: if you use the command “1- “ indicate 1st column till the end.

2. xargs command can be also use to display a full content.


Linux command: xargs -L1 < test100.txt

Note: if you don’t use any argument, it will treat as standard output and it will suppress the
new line, using L1 is using to print every line after newline.

3. Using perl command can also use to print all lines.


Linux command: perl -pne ‘ ’ test100.txt
Note: e option to enable command line, -n is to make it in loop to print and -p is to print every
line.

4. Other variant of perl command.


Linux command: perl -ne ‘print; ’ test100.txt

5. Other variant of perl command.


Linux command: perl -ne ‘print $_; ’ test100.txt

Note: using $_ is variable which will trying every line get printed.

Bonus: scripting of file reading.

while read line

do

echo $line

done < test100.txt

You might also like