The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Carreer:Networking Programming in Unix (C programming Language) vibhory2j UNIX for Dummies Questions & Answers 5 09-05-2008 07:57 PM
Unix Systems Programming Vs Unix Programming BCarlson Shell Programming and Scripting 0 05-24-2006 02:34 PM
RPC Programming emeralddream High Level Programming 1 02-23-2005 11:34 AM
c programming or unix programming!? moxxx68 High Level Programming 1 03-30-2004 08:53 AM
Programming CreamHarry High Level Programming 3 03-07-2002 03:09 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-30-2008
xkayla06 xkayla06 is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
Cool New To Programming

Hello all!!
I am new to programming, and to this forum.
I am having sort of a problem. Me and my coworker are working on a code, both of us are stumped on a few things.
One is we have a whole log file, i have found how to extract by column, but not by row. I need to extract by both.


For example..
I need rows 302 - 463
and columns 53-68
This is just a small portion of the log file, but it is all i need to "compare" to another file.

i hope this is clear enough for everyone, please feel free to ask any other questions if not.


thanks =)
  #2 (permalink)  
Old 05-30-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,293
Can you show us what you and your coworker have attempted so far?

Regards
  #3 (permalink)  
Old 05-30-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink extracting data from a file

I need rows 302 - 463
Code:
>cat mylog | head -463 | tail -162
the head takes the first 463 lines
the tail takes the last 162 (remember to add one; for example if I want lines 99 and 100 that is two lines!)

and columns 53-68
Code:
>cat mylog | cut -c53-68
Note that these two can be put together as
Code:
>cat mylog | head -463 | tail -162 | cut -c53-68
  #4 (permalink)  
Old 05-30-2008
siba.s.nayak siba.s.nayak is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 164
It would be better if we use -f in stead of -c in cut command.

Quote:
Originally Posted by joeyg View Post
I need rows 302 - 463
Code:
>cat mylog | head -463 | tail -162
the head takes the first 463 lines
the tail takes the last 162 (remember to add one; for example if I want lines 99 and 100 that is two lines!)

and columns 53-68
Code:
>cat mylog | cut -c53-68
Note that these two can be put together as
Code:
>cat mylog | head -463 | tail -162 | cut -c53-68
  #5 (permalink)  
Old 05-30-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Question Confused about request -f vs -c in cut

Quote:
siba.s.nayak
It would be better if we use -f in stead of -c in cut command.
the -f parameter is for fields separated by a delimeter character, that may be set by a -d parameter

the -c parameter extracts data based on absolute character position

Based on the initial user request
Quote:
and columns 53-68
the -c option accomplishes this. I have no idea how the -f could do the same.
  #6 (permalink)  
Old 05-30-2008
xxmenxx xxmenxx is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 12
if u can get the row number, u can use "sed" as following
sed -e '1,301d' -e '364,$d' mylog >log_result

as it delete from row number 1 to numer 301 , and from 364 to the end of ur log, then write the rest of the log to log_result
  #7 (permalink)  
Old 05-30-2008
xkayla06 xkayla06 is offline
Registered User
  
 

Join Date: May 2008
Posts: 2
Thanks again everyone,
I have another question
I have two files, that have the same data in them excluding a few things. I want to compare these two files but they are not in the same order.

for example..
all of the data in the file looks similar to this

E00401001D011029
E00401001D01102D

etc
but they are not in the same order, and when i use the diff file.txt file2txt command it spits out a bunch of random stuff that i dont want, i just want to compare the two files and find the differances. Is there a way i can sort them so they look alike and then it will find the differances? or is there a way i can look through them and find the differances that way.


Thanks a bunch!
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 01:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0