The cat command is used to create a file.
syntax: $ cat > filename
#To create a new file
bash-2.02$ cat> program.c
int main()
{
printf(Hi helllo ");
return 0;
}
#To create another file
bash-2.02$ cat >program2.c
int function()
{
printf("I am in Second source code\n");
return 0;
}
# to display the file content
bash-2.02$ cat program2.c
int function()
{
printf("I am in Second source code\n");
return 0;
}
# here concatenate multiple files
bash-2.02$ cat program.c program2.c >Testfile.txt
# To display the content
bash-2.02$ cat Testfile.txt
int main()
{
printf(Hi helllo ");
return 0;
}
int function()
{
printf("I am in Second source code\n");
return 0;
}
# To store the line number
bash-2.02$ cat -n program.c program2.c > Testfile.txt
# To display the modified content
bash-2.02$ cat Testfile.txt
1 int main()
2 {
3 printf(Hi helllo ");
4 return 0;
5 }
6 int function()
7 {
8 printf("I am in Second source code\n");
9 return 0;
10 }
bash-2.02$
No comments:
Post a Comment