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
Odd .sh behavior in script robertmcol UNIX for Dummies Questions & Answers 2 02-10-2008 10:22 AM
ltoa Behavior charitonca HP-UX 2 07-13-2006 06:29 PM
ls behavior AtleRamsli High Level Programming 10 03-26-2002 07:31 AM
Telnet behavior piltrafa UNIX for Dummies Questions & Answers 4 10-31-2001 03:49 PM

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-04-2007
andy2000 andy2000 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 36
sed behavior on hp-ux

the sed command:

sed 's/^[ \t]*//' file

does not work on HP-UX :-( but it works fine on Linux,

content of file:
<tab><tab>hello

output should be:
hello

Any ideas??

Thank you

Andy

Last edited by andy2000; 05-04-2007 at 02:19 PM..
  #2 (permalink)  
Old 05-04-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
sed 's/^[ \t]*//' file
where \t is the actual tab character typed in from the terminal - note the last /
  #3 (permalink)  
Old 05-04-2007
andy2000 andy2000 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 36
Sorry, but I 've said:

sed 's/^[ \t]*//' file # works only on Linux but NOT on HP-UX
  #4 (permalink)  
Old 05-04-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
I ran it on HPUX 11.0 and 11.23 works just fine. There must be something else other than your sed command going on. The sed string you have removes ONE tab not all of them. Is that what you mean by 'does not work' ?

Code:
sed 's/^[ \t]*//g'
will remove all of them
  #5 (permalink)  
Old 05-04-2007
andy2000 andy2000 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 36
Jim,

please try the command to remove a lot of white spaces:

content of file:
<space><space><tab><space><tab><space><tab>hello

Andy
  #6 (permalink)  
Old 05-04-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Code:
sed 's/^[        ]*//' file
doee not work, you are correct

Code:
kcsdev:/home/jmcnama> echo "                             hello" | sed 's/^[        ]*//'
hello
It does work on stdin.
Code:
kcsdev:/home/jmcnama> sed 's/^[        ]*//' < file
                                 hello
kcsdev:/home/jmcnama> cat file | sed 's/^[        ]*//'
                                 hello
It just refuses to work on a file, regardless of whether it is stdin or not. That does not make sense.

This works on a file:
Code:
while read record
do
     echo $record |  sed 's/^[        ]*//
done < file > newfile
I do not understand, but it is a workaround.
Closed Thread

Bookmarks

Tags
linux

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 12:24 AM.


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