nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Omit the first line in a file

This is a discussion on Omit the first line in a file within the Shell scripting forums, part of the Development/Scripting category; Hello, When I try to join 2 files, I need to omit the first line of the files. How do ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 12-25-2006, 04:06 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
c341
Default Omit the first line in a file

Hello,

When I try to join 2 files, I need to omit the first line of the files.

How do I omit it??? :roll:

Thank You
Best Regards - Joe
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-25-2006, 08:49 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

To omit something from file use grep command
Code:
grep -v "word-to-omit" filename
Above command will omit any matching word. To just remove/omit first line use combination of wc and tail -f command:
Code:
tail -n $(wc -l filename | awk  '{ print $1-1}') filename
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 12-29-2006, 11:39 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Rep Power: 0
c341
Default

Thanks A Lot, It Worked!!!
Reply With Quote
  #4 (permalink)  
Old 12-29-2006, 02:11 PM
Ash Ash is offline
Junior Member
 
Join Date: Dec 2006
Posts: 1
Rep Power: 0
Ash
Default Re: Omit the first line in a file

Code:
sed 1d filename
Just to do honour to sed, one of my best software friends.
Reply With Quote
  #5 (permalink)  
Old 12-29-2006, 03:07 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Ash welcome to nixCraft forum.

Thanks for quick and dirty solution. I almost forget nifty sed.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
HPUX Unix comparing 2 large files line by line raj HP-UX 1 02-11-2008 06:20 PM
Spliting files each line by using token anilvrathod Shell scripting 0 12-08-2007 03:00 PM
Command line remote access angelus_kit Networking, Firewalls and Security 7 09-05-2007 07:30 PM
SED pass a output line to another cillo Shell scripting 6 11-01-2006 02:59 PM
for do loop in solaris one line Solaris/OpenSolaris 1 01-09-2006 02:35 PM


All times are GMT +5.5. The time now is 08:50 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36