nixCraft Linux Forum

nixCraft

Linux / UNIX 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 ...

Register free or login to your existing account and remove all advertisements.


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

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-25-2006, 03:06 PM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
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
  #2 (permalink)  
Old 12-25-2006, 07:49 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,677
Thanks: 11
Thanked 240 Times in 180 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 12-29-2006, 10:39 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
c341
Default

Thanks A Lot, It Worked!!!
Reply With Quote
  #4 (permalink)  
Old 12-29-2006, 01:11 PM
Ash Ash is offline
Junior Member
User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
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, 02:07 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,677
Thanks: 11
Thanked 240 Times in 180 Posts
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 Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


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 Off


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 05:20 PM
Spliting files each line by using token anilvrathod Shell scripting 0 12-08-2007 02:00 PM
Command line remote access angelus_kit Networking, Firewalls and Security 7 09-05-2007 06:30 PM
SED pass a output line to another cillo Shell scripting 6 11-01-2006 01:59 PM
for do loop in solaris one line Solaris/OpenSolaris 1 01-09-2006 01:35 PM


All times are GMT +5.5. The time now is 01:52 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

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 37 38