need help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help
# 1  
Old 03-27-2008
need help

Dear all

There is a file called f1, having contents

1
2
3
4
.
.
.
0

Before 0, I don't know how many lines are there. I need to remove last line and save the output to file name called f2
# 2  
Old 03-27-2008
Code:
sed '$d'

Applying it left as an exercise, as this is doubtlessly an assignment.
# 3  
Old 03-27-2008
for large files, use head
Code:
# head -n -1 file

# 4  
Old 03-27-2008
That's neat, but not very portable. Is that a GNUism or a POSIXism?
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question