stripping last lien off a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers stripping last lien off a file
# 1  
Old 05-30-2005
stripping last lien off a file

Hi,
how can i strip the last line off my file using shell script?

Thanks and Regards
Vivek.S
# 2  
Old 05-30-2005
Quote:
Originally Posted by vivekshankar
Hi,
how can i strip the last line off my file using shell script?

Thanks and Regards
Vivek.S
  1. By following the directions in the previous threads
  2. By reading FAQs at this forum
  3. By searching other sources [e.g. google]
  4. By experimenting on your own with the gained knowledge and coming back iwth the concrete questions
  5. If everything else fails, goto 1
# 3  
Old 05-31-2005
Quote:
Originally Posted by vivekshankar
Hi,
how can i strip the last line off my file using shell script?

Thanks and Regards
Vivek.S
Hi !
Try to read manual pages for wc and head. It's very simple to do it... but anyway, folowing the vgersh99's algorithm I'm sure you'll find hundereds of new solutions ;-)
Good luck !
# 4  
Old 05-31-2005
In addition with what vgersh99 and Sergiu-IT has to say, this is what you might be looking for.

Code:
#! /bin/sh
sed -e '$d' inputfile > inputfile.tmp && mv inputfile.tmp inputfile

vino
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Stripping ret of the lines in a file (sed question)

Hi all, I didn't use SED for 20 years and was never an expert. So my current knowledge is about zero. Please be patient with me. I'm neither a native speaker. I have a huge dictionary file and want the rest of the lines stripped. Everything after (and including) the "/" should be stripped. I... (2 Replies)
Discussion started by: Hinnerk2005
2 Replies

2. Shell Programming and Scripting

Stripping characters from a file and reformatting according to another one

Dear experts, my problem is pretty tricky. I want to change a file (see attached input.txt), according to another file (help.txt). The output that is desired is in output.txt. The example is attached. Note that -dashes should not be treated specially, they are considered normal characters,... (2 Replies)
Discussion started by: TheTransporter
2 Replies

3. Homework & Coursework Questions

Help with file stripping shell script

Well my last assignment came and i tried some things but i guess it's pretty puzzling for me to figure out all the points of the problem. I was able to achieve something but it's not complete. 1. The problem statement, all variables and given/known data: Write a bash program which strips the... (5 Replies)
Discussion started by: Florinel76
5 Replies

4. Shell Programming and Scripting

Stripping out extensions when file has multiple dots in name

I posted this already in another thread, but was told that I should create a seperate thread for the following question: How do I strip the extension when the delimiter might occur multiple times in the filename? For example: I have 2 files as input for my script. test.extension... (8 Replies)
Discussion started by: Nemelis
8 Replies

5. Shell Programming and Scripting

Stripping out extension in file name

This command gives me just the filename without any extension: evrvar =`echo filename.tar | sed 's/\.*$//'` I am trying to make a change to this command... to make it work for... filename.tar.gz to get just the filename.... currently the command gives me filename.tar by removing only gz... I... (9 Replies)
Discussion started by: devs
9 Replies

6. Shell Programming and Scripting

Stripping out the extension of a file name

I have written a shell script and in my script i have a variable filename=myfile.txt now, i want another variable to be defined for which i have to strip out the extension fo the file name, i.e. newvariable= myfile how do i strip out the ".txt" part from my first variable. Any kind of help... (4 Replies)
Discussion started by: ramky79
4 Replies

7. Shell Programming and Scripting

Stripping out the extension of a file name

I have two variables to be dynamically defined in my shell script variable1= myfile.txt variable2= myfile The second variable depends on the first ( i mean , it is a part of the first variable) Now, I need to strip out the ".txt" part from the first variable how do i do that in a shell script. (2 Replies)
Discussion started by: ramky79
2 Replies

8. Shell Programming and Scripting

stripping out certain charecters

we are ftping zipped up files from the development server to the production server daily.The files are in this format filename.dat.20061231.12131.gz I have to unzip the file (i can do that with gunzip) and then strip out the timestamp after the .dat extension. I can do something like this ... (4 Replies)
Discussion started by: mervin2006
4 Replies
Login or Register to Ask a Question