New To Programming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting New To Programming
# 1  
Old 05-30-2008
Tools New To Programming

Hello all!!
I am new to programming, and to this forum. Smilie
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.Smilie


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  
Old 05-30-2008
Can you show us what you and your coworker have attempted so far?

Regards
# 3  
Old 05-30-2008
Hammer & Screwdriver 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  
Old 05-30-2008
It would be better if we use -f in stead of -c in cut command.

Quote:
Originally Posted by joeyg
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  
Old 05-30-2008
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  
Old 05-30-2008
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  
Old 05-30-2008
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!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

From iOS programming to Linux system programming

Hello. I like Linux and C programming language. Allways wanted to understand kernel and become a Linux system programmer. And I also like Objective-C and iOS. These two programming areas have relations: 1. Linux and iOS are UNIX-like systems, POSIX compliant. 2. It is useful to know C language... (2 Replies)
Discussion started by: Rockatansky
2 Replies

2. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

3. Shell Programming and Scripting

Sh programming

I have started writing one script. It is not taking the if block. Here is the script: #!/bin/sh set USER='/usr/ucb/whoami' ####################################################################### #Killing Process #######################################################################... (6 Replies)
Discussion started by: amarpreetka
6 Replies

4. Programming

C Programming - Hardware Programming

Can someone help me on suggesting some ways to access the memory content in RAM directly from C/C++ source code. Please provide me any book name or any URL so that I can get an exhaustive knowledge over it. If possible please give me some tips on interacting with hardwares directly through... (3 Replies)
Discussion started by: nandumishra
3 Replies

5. Programming

programming in C

Hi Guys, I am willing to write some programs in C/C++ for Solaris machine. I am pretty good in C++ programming for PC. But I have some questions, while starting programming in solaris. 1. Which one is the most suitable & easy to use compiler? (Most probabaly I will use vi editor to edit... (4 Replies)
Discussion started by: Asteroid
4 Replies

6. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

7. Programming

C++ programming

Sorry to ask this question here... where can I find a C++ programming thread? Thanks guys! (7 Replies)
Discussion started by: nadiamihu
7 Replies

8. Shell Programming and Scripting

Unix Systems Programming Vs Unix Programming

Several months ago I found a link that explained the difference between how a Unix Systems Admin would do scripting compared to what a Unix Programmer would do. It showed a basic script and then show several iterations that explained how the Systems Admin would change it to make it better. I was... (0 Replies)
Discussion started by: BCarlson
0 Replies

9. Programming

c programming or unix programming!?

i would like advice on the usbject of c programming (in the middle of reading a book on C). could i benefit more if i apply that knowledge in the unix format if i were able to, or would that take the point out of learning C, basically I want to stay away from strying too far away from unix and use... (1 Reply)
Discussion started by: moxxx68
1 Replies

10. Programming

c programming on vi

i am new in linux environment .I have used vi editor of Unix to get a programe compiled through "gcc ".kindly give me the options to get a program compiled & executed written in c on vi editor. I want the command to compile a file and the command to get that compiled file executed with any... (2 Replies)
Discussion started by: Rajraius
2 Replies
Login or Register to Ask a Question