Linux command for file view: more, less, head, tail, cat

1) more = to view a text file one page at a time, press spacebar to go to the next page

more filename : show the document one page at a time

more -num filename : show the document page few lines as specified bu (-num)

example : more -10 filename will show 10 lines for every page

.

2) less = is much the same as more command except:

a) You can navigate the page up/down using the less command and not possible in more command.

b) You can search a string in less command. (use /keywordto search)

c) “more” was fairly limited, and additional development on “more” had stopped

d) it uses same functions as vi editor

the usage : less filename

.

3) head = displays the first ten lines of a file, unless otherwise stated.

Examples

head myfile.txt – Would display the first ten lines of myfile.txt.

head -15 myfile.txt – Would display the first fifteen lines of myfile.txt.

.

4) tail = display the last part of the file

usage : tail filename

tail -n filename : display the last n lines of the file

.

5) cat = can be used to join multiple files together and print the result on screen (it will not show page by page)

usage:

cat 01.txt
to displat the contents of file 01.txt

cat 01.txt 02.txt
to display the contents of both files

cat file1.txt file2.txt > file3.txt – Reads file1.txt and file2.txt and  combines those files to make

cat note5 >> notes – attach note5 to notes

cat >> file1 – add additional data in file1

Linux command for file view: more, less, head, tail, cat

1) more = to view a text file one page at a time, press spacebar to go to the next page

more filename : show the document one page at a time

more -num filename : show the document page few lines as specified bu (-num)

example : more -10 filename will show 10 lines for every page

.

2) less = is much the same as more command except:

a) You can navigate the page up/down using the less command and not possible in more command.

b) You can search a string in less command. (use /keywordto search)

c) “more” was fairly limited, and additional development on “more” had stopped

d) it uses same functions as vi editor

the usage : less filename

.

3) head = displays the first ten lines of a file, unless otherwise stated.

Examples

head myfile.txt – Would display the first ten lines of myfile.txt.

head -15 myfile.txt – Would display the first fifteen lines of myfile.txt.

.

4) tail = display the last part of the file

usage : tail filename

tail -n filename : display the last n lines of the file

.

5) cat = can be used to join multiple files together and print the result on screen (it will not show page by page)

usage:

cat 01.txt
to displat the contents of file 01.txt

cat 01.txt 02.txt
to display the contents of both files

cat file1.txt file2.txt > file3.txt – Reads file1.txt and file2.txt and  combines those files to make

cat note5 >> notes – attach note5 to notes

cat >> file1 – add additional data in file1

Empty Trash Bin from Command Line

If you can not empty your trash bin due to some permission error as a regular user, you can do it use command in terminal

sudo rm -rf  ~/.Trash/

Empty Trash Bin from Command Line

If you can not empty your trash bin due to some permission error as a regular user, you can do it use command in terminal

sudo rm -rf  ~/.Trash/

Use Array/reference as argument for Perl sub-routine

如果我们在参数中传递两个数组的时候,会出现一些问题。

sub getarrays{

    my(@a,@b) = @_;

.

.

}

@fruit = qw(apples oranges banana);

@veggies = qw(carrot cabbage turnip);

getarrays(@fruit, @veggies);

上面这段代码我们预期 @fruit 会赋值给@a,@veggies赋值给@b,但其实结果不是那样的。

在调用getarrays(@fruit, @veggies)的时候,其把参数@fruit 和 @veggies压缩到单个数组@_中。

这样在getarrays函数内部,就会把@_赋值给@a,即就是@fruit和@veggies都赋值给@a了。

我们根本无法知道一个数组何时结束 以及下一个数组何时开始,因为我们只知道@_.

这时传递参数引用可以很好的解决这个问题。即我们没有必要传递整个数组,只要传递相关数组的引用就可以了。

sub getarrays{

    my($fruit_ref,$veg_ref) = @_;

.

.

}

@fruit = qw(apples oranges banana);

@veggies = qw(carrot cabbage turnip);

getarrays(\@fruit, \@veggies);

函数getarrays()总是接收两个值,即两个引用,无论这些引用指向的数组有多长。这时,

$fruit_ref和$veg_ref可以用来显示或编辑数据,如下所示:

sub getarrays{

    my($fruit_ref,$veg_ref) = @_;



print "Fruit:" ,join(',', @$fruit_ref);

print "Veggies:",join(',', @veggies_ref);

}

当你将对标量、数组或哈希结构的引用作为参数传递给函数时,有几个问题必须记住。

当你传递引用时,函数能够对引用指向的原始数据进行操作

所以在使用引用的时候我们应该注意这一点。

Use Array/reference as argument for Perl sub-routine

如果我们在参数中传递两个数组的时候,会出现一些问题。

sub getarrays{

    my(@a,@b) = @_;

.

.

}

@fruit = qw(apples oranges banana);

@veggies = qw(carrot cabbage turnip);

getarrays(@fruit, @veggies);

上面这段代码我们预期 @fruit 会赋值给@a,@veggies赋值给@b,但其实结果不是那样的。

在调用getarrays(@fruit, @veggies)的时候,其把参数@fruit 和 @veggies压缩到单个数组@_中。

这样在getarrays函数内部,就会把@_赋值给@a,即就是@fruit和@veggies都赋值给@a了。

我们根本无法知道一个数组何时结束 以及下一个数组何时开始,因为我们只知道@_.

这时传递参数引用可以很好的解决这个问题。即我们没有必要传递整个数组,只要传递相关数组的引用就可以了。

sub getarrays{

    my($fruit_ref,$veg_ref) = @_;

.

.

}

@fruit = qw(apples oranges banana);

@veggies = qw(carrot cabbage turnip);

getarrays(\@fruit, \@veggies);

函数getarrays()总是接收两个值,即两个引用,无论这些引用指向的数组有多长。这时,

$fruit_ref和$veg_ref可以用来显示或编辑数据,如下所示:

sub getarrays{

    my($fruit_ref,$veg_ref) = @_;



print "Fruit:" ,join(',', @$fruit_ref);

print "Veggies:",join(',', @veggies_ref);

}

当你将对标量、数组或哈希结构的引用作为参数传递给函数时,有几个问题必须记住。

当你传递引用时,函数能够对引用指向的原始数据进行操作

所以在使用引用的时候我们应该注意这一点。

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...