The UNIX and Linux Forums  

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
how to access values of awk/nawk variables outside the awk/nawk block? saniya Shell Programming and Scripting 5 05-13-2008 08:37 AM
nawk question DeltaX Shell Programming and Scripting 10 03-06-2008 08:51 PM
nawk/ksh help DeltaX Shell Programming and Scripting 0 03-06-2008 03:54 PM
nawk -v to awk kamel.seg Shell Programming and Scripting 2 12-18-2007 07:30 AM
nawk whatisthis Shell Programming and Scripting 3 09-29-2004 02:44 PM

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

Join Date: Jan 2008
Posts: 16
NAWK question

Hello everybody !!

I just started messing around with NAWK/AWK and I find it very interesting. I was trying to have script that prints only the the different lines (lines that are identical and adjacent, some that are identical and not adjacent, and some that are just different)

I tried direclty using the command line (awk '$1 != previous { print; previous = $1 }' file)

I am trying to do it in a script.

Your help will be appreciated
  #2 (permalink)  
Old 01-28-2008
DeltaX DeltaX is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 16
I think I figured it out !!

Thanks anwyays.


I have another question

I'm trying to do a fold script similar to the one built in the system. For ex, let say I wanna fold lines at 80 columns ( given input with lines that are 120 columns long, it prints the first 80 characters of each line, a new line, and then the remaining 40 characters )

Thanks in advance
  #3 (permalink)  
Old 01-28-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 753
Quote:
Originally Posted by DeltaX View Post
I think I figured it out !!

Thanks anwyays.


I have another question

I'm trying to do a fold script similar to the one built in the system. For ex, let say I wanna fold lines at 80 columns ( given input with lines that are 120 columns long, it prints the first 80 characters of each line, a new line, and then the remaining 40 characters )

Thanks in advance

Code:
awk '{s1=substr($0,1,80);s2=substr($0,81);print s1;print s2}' file

  #4 (permalink)  
Old 01-28-2008
DeltaX DeltaX is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 16
Thanks,

How can I do that in a script
  #5 (permalink)  
Old 01-29-2008
DeltaX DeltaX is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 16
Im just tryin to learn how to do things in script form, not in command line.
  #6 (permalink)  
Old 01-29-2008
DeltaX DeltaX is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 16
Thanks shamrock

I did figure out.

Is there a way where I can input the columns number at the command line ? or not
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 08:30 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