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
continue example xramm Shell Programming and Scripting 7 07-03-2007 04:10 AM
Continue Script when File Found Jose Miguel Shell Programming and Scripting 7 11-07-2006 08:43 PM
Continue an 'scp' tranfser? deckard UNIX for Advanced & Expert Users 3 12-19-2005 05:08 PM
Will the continue function work ???? kamlesh_p Shell Programming and Scripting 2 10-12-2005 09:27 AM
continue the suspended jobs killerserv UNIX for Advanced & Expert Users 6 01-10-2002 03:09 AM

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 03-09-2008
anhtt anhtt is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 22
awk continue

I want to print entire row of file

awk '{print $0}' inputfile

but sometime before every row have space characters. Example:
" HVLR is not in service on AP 54"

How can i print entire row without space characters ?

thanks
  #2 (permalink)  
Old 03-09-2008
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 167

Code:
#delete leading whitespace (spaces, tabs) from front of each line
awk '{sub(/^[ \t]+/, ""); print}'

#delete BOTH leading and trailing whitespace from each line (also removes extra space between fields)
awk '{$1=$1;print}'

//Jadu
  #3 (permalink)  
Old 03-10-2008
dmwaff dmwaff is offline
Registered User
  
 

Join Date: Aug 2001
Location: Texas
Posts: 17
If you are not tied to awk. Sed works on removing leading and trailing whitespace.

awk '{print $0 }' inputFile |sed -e 's/^ //g' -e 's/ $//g'
or
sed -e 's/^ //g' -e 's/ $//g' inputFile
  #4 (permalink)  
Old 03-11-2008
shahidbakshi shahidbakshi is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 10
Hi...

you can try this..
sed 's/^[ \t]*//' yourfile name

regards
Shahid
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 04:49 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