How to add content of one file into another file at the beginning

Answers were Sorted based on User's Feedback



How to add content of one file into another file at the beginning..

Answer / tejaswa

Hi Durgesh, by this command you can add the content at the end of file2 not in the beginning.

Is This Answer Correct ?    16 Yes 4 No

How to add content of one file into another file at the beginning..

Answer / pritam sahu

cat fil2 file1>>file3 then rename the file3 as file2 by mv
file3 file2.

Is This Answer Correct ?    6 Yes 2 No

How to add content of one file into another file at the beginning..

Answer / dick

concatenate file1 and file2, in the below command file1 content will be insert in front of that in file2, and then combined content will be redirected to file3

cat file1 file2 > file3

Is This Answer Correct ?    8 Yes 5 No

How to add content of one file into another file at the beginning..

Answer / preet mala

If we want to add content of file1 at the beginning of file2
then use the following command:-


cat file2 file1 >> file3 | mv file3 file2;

Is This Answer Correct ?    2 Yes 0 No

How to add content of one file into another file at the beginning..

Answer / rakesh kumar ray

cat > file1
rakesh
kumar
ray
cntrl + d

cat > file2
rintu
rohan
rocky
cntrl +d

cat < file1 > file2

Is This Answer Correct ?    2 Yes 1 No

How to add content of one file into another file at the beginning..

Answer / shilpi gupta

cat file1 file2 >>file3|mv file3 file2

Is This Answer Correct ?    1 Yes 0 No

How to add content of one file into another file at the beginning..

Answer / boss

cat file1 file2 > tmp && mv tmp file2

Is This Answer Correct ?    1 Yes 0 No

How to add content of one file into another file at the beginning..

Answer / green

(To insert file2 content to file1; then the command is)
vi file1
(in command mode)
:0 r! cat file2 (press enter)

( file2 content is inserted to file1 )

Is This Answer Correct ?    0 Yes 0 No

How to add content of one file into another file at the beginning..

Answer / ahmed

Use sed command
sed -i'' '1 i this is firts line' temp123

Is This Answer Correct ?    1 Yes 2 No

How to add content of one file into another file at the beginning..

Answer / abhishek bhardwaj

If one wants to add content of file1 on top of file2 then

cat file2 >> file1

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More Unix Commands Interview Questions

How to get a particular string as your prompt ? Give syntax of that command?

3 Answers  


What is awk command used for?

0 Answers  


Explain the read, write, and execute permissions on a UNIX directory.

5 Answers  


Write a command that will output the sorted contents of a file named in.txt and place the output in another file named out.txt, while at the same time excluding duplicate entries.

1 Answers  


Explain the terms ‘system calls’ and ‘library functions’ with respect to unix commands?

0 Answers  






which script will invoke first ,when /etc/init.d starts

1 Answers  


What does sed command do in unix?

0 Answers  


What is the use of egrep command in unix?

0 Answers  


Hi All, Can you please let me know how to grep for a particular pattern in unix. I want to print the dates from the file exp.txt. the date pattern is DD:MM:YYYY, I just want to print all the dates from the file exp.txt.

8 Answers   Concentrix, IBM, Symantec, TCS,


What is the procedure of "at" and crontab" commands?

4 Answers  


What is the difference between a hard link and a soft link in Unix?

1 Answers  


What are some command words?

0 Answers  


Categories