Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Command to remove First and Last line from a File Post 302350190 by ragz_82 on Thursday 3rd of September 2009 04:45:06 AM
Old 09-03-2009
Command to remove First and Last line from a File

I have a file from which the Header and the Trailer lines need to be removed. They are confirmed to be the first and the last lines in the file.

I have tried a few commands, but not successful yet. It needs to be implemented urgently, hence any help is greatly appreciated.

Raghu

---------- Post updated at 02:15 PM ---------- Previous update was at 02:00 PM ----------

Just found out from another post in this forum, that the following command works perfectly:

sed -e '2,$!d' -e '$d' file

replace 'file' with your filename.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove header(first line) and trailer(last line) in ANY given file

Hi, I need some help in removing the header (first line) and the trailer (last line) in a give file... The data file actually comes in EBCDIC format and I converted it into ASCII.. Now I need to strip off the first line and the last line.. I think we can use sed to do something like this:... (2 Replies)
Discussion started by: madhunk
2 Replies

2. Solaris

How to remove user from a group using command line

Hi, Wanted to remove a user from a group , but no GUI , must use command line (2 Replies)
Discussion started by: civic2005
2 Replies

3. Shell Programming and Scripting

How to remove those sequence with same amino acid?What command line I should type?

My input is listed as: giNumber RefAminoAcid VarAminoAcid 10190711 P P 10190711 D D 109255248 I A 110349771 A ... (4 Replies)
Discussion started by: patrick chia
4 Replies

4. Shell Programming and Scripting

How can I remove those duplicate sequence in UNIX?What command line I should type?

The input is: >HWI-EAS382_30FC7AAXX:4:1:1580:1465 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >HWI-EAS382_30FC7AAXX:4:1:1062:1640 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA >HWI-EAS382_30FC7AAXX:4:1:272:629 AAAAAAAAGCTATAGTCTCGTCACACATACTCACAA >HWI-EAS382_30FC7AAXX:4:1:1033:1135... (4 Replies)
Discussion started by: patrick chia
4 Replies

5. Shell Programming and Scripting

Remove Command-Line Option from String

I want to add a "-r <remote_host>" option to my ksh script, causing the script to run a script of the same name on the specified remote host. The remote invocation should itself include all the command-line options of the original invocation, less the -r option. For example, this invocation: ... (7 Replies)
Discussion started by: mattmiller
7 Replies

6. Shell Programming and Scripting

How to remove unwanted elements from the command line?

CREATE TYPE "SUPERB"."OE_L2_FOOTERDATA_REC" OID '1232323232' IS OBJECT ( AWLSTrxId NUMBER, AdjPurchaseAmount NUMBER, Network NUMBER, ConfigVersion NUMBER ); / I wanted my output to be as follow: CREATE TYPE OE_L2_FOOTERDATA_REC OID '1232323232'... (7 Replies)
Discussion started by: jediwannabe
7 Replies

7. UNIX for Dummies Questions & Answers

Cut command doesn't remove (^C) character from only first line

I have a file which has first 2 junk characters(X^C) at beginning of each line in file. When i run cut -c 2- filename it removes junk characters from all lines except on first line it keeps one junk character control C(^C). Not sure why it is not removing only from first line. (2 Replies)
Discussion started by: later_troy
2 Replies

8. Shell Programming and Scripting

Remove line from file and read file line by line

I have a file output.txt. File looks like this name1 10 name2 2 name3 5 I get a number n and I need to remove all lines which has number (after name) smaller or equal to n number. After that I need to write lines from file and my output must be like this: Output: 'name1 10' Output: 'name2... (1 Reply)
Discussion started by: kubo12312
1 Replies

9. UNIX for Beginners Questions & Answers

Need a command to remove the last word in the first line of a file

I have a eg file op.txt This is a cat This is a fat cat This is a fat black cat I want to remove only the word cat from the first alone .can somebody help. please do wrap your samples in CODE TAGS As per forum rules. (7 Replies)
Discussion started by: Sharks
7 Replies
uuencode(4)						     Kernel Interfaces Manual						       uuencode(4)

NAME
uuencode - format of an encoded uuencode file DESCRIPTION
Files output by consist of a header line followed by a number of body lines, and a trailer line. The command ignores any lines preceding the header or following the trailer (see uuencode(1)). Lines preceding a header must not look like a header. The header line consists of the word followed by a space, a mode (in octal), another space, and a string which specifies the name of the remote file. The body consists of a number of lines, each containing 62 or fewer characters (including trailing new-line). These lines consist of a character count, followed by encoded characters, followed by a newline. The character count is a single printing character, which represents an integer. This integer is the number of bytes in the rest of the line, and always ranges from 0 to 63. The byte count can be determined by subtracting the equivalent octal value of an ASCII space charac- ter (octal 40) from the character. Groups of 3 bytes are stored in 4 characters, 6 bits per character. All are offset by a space to make the characters printable. The last line may be shorter than the normal 45 bytes. If the size is not a multiple of 3, this fact can be determined by the value of the count on the last line. Extra meaningless data will be included, if necessary, to make the character count a multiple of 4. The body is terminated by a line with a count of zero. This line consists of one ASCII space. The trailer line consists of the word on a line by itself. SEE ALSO
mail(1), uuencode(1), uucp(1). uuencode(4)
All times are GMT -4. The time now is 03:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy