The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-17-2008
sdosanjh sdosanjh is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 27
Append the file in UNIX

Hello All,

Could you please provide the solution to my following query
I have some files in my directory. I need to amend the total number of
lines to be added in the starting
line of each file.

For example, please refer the content of the file "file.dat" below.

\h:\w #> cat file.dat
hai
hello
end
Nice day
\h:\w #>

After your command, the output should be below.

\h:\w #> cat file.dat
Total no. of lines: 4
hai
hello
end
Nice day
\h:\w #>

We can do this in sed and awk through a single command. But we will
avoid the sed and awk stuff's for some time.
and can just try using simple unix commands for now.

Regards,
Sandeep