What is the use of Custom end marker (<<) in Linux - The Tech Influences

0

What is the use of Custom end marker (<<) in Linux

We use this command in Linux, like we are creating a file using cat command and inside that we will define the string that wherever this word will appear in the file then the file will be saved automatically.

 

If you do not understand then you can see the example

 

Example:-1

Like here I am creating a file named file1.txt and define a string named stop, wherever this word will appear in the file, the file will be saved automatically.

[root@redhat-1 test]# cat > file1.txt << stop
> Hello
> how are you
> what are you doing
> where are you from
> stop
[root@redhat-1 test]# ll
total 4
-rw-r--r--. 1 root root 57 Jul  9 23:02 file1.txt
[root@redhat-1 test]# cat file1.txt
Hello
how are you
what are you doing
where are you from
[root@redhat-1 test]#

Here you can see that after the stop name in the file, the file will be automatically saved.


Example:-2

Like here I am creating a file named file2.txt and define a string named 10, wherever this word will appear in the file, the file will be saved automatically.

[root@redhat-1 test]# cat > file2.txt << 10
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
[root@redhat-1 test]# ls
file1.txt  file2.txt
[root@redhat-1 test]# cat file2.txt
1
2
3
4
5
6
7
8
9
[root@redhat-1 test]#

Here you can see that after the 10 word name in the file, the file will be automatically saved.



Post a Comment

0Comments
Post a Comment (0)