Sponsored Content
Full Discussion: Trim white spaces using awk
Top Forums Shell Programming and Scripting Trim white spaces using awk Post 302081838 by aigles on Friday 28th of July 2006 04:40:31 AM
Old 07-28-2006
Your statement is valid for one space, insert it in your AWK program :
Code:
/FOOTER/ {gsub(/ /,"",$3); print "set RecordsFound=" $3}

To suppress multiple spaces :
Code:
/FOOTER/ {gsub(/ */,"",$3); print "set RecordsFound=" $3}

Perhaps your field contains tabulation, modify the gsub statement :
Code:
/FOOTER/ {gsub(/[[:space:]]*/,"",$3); print "set RecordsFound=" $3}

jean-Pierre.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To Trim spaces at the end of line

Hi Friends, Can any one help with this issue: How to trim spaces for each line at the end, Like I have a file in this format. EMP1 SMITH 46373 5 STREET HOWARD 74636 EMP2 JONES 5454 { these are spaces ........} EMP3 SMITH 46373 5 STREET HOWARD 74636 EMP4 JON 2554 { these are... (1 Reply)
Discussion started by: sbasetty
1 Replies

2. UNIX for Advanced & Expert Users

TRIM spaces in shell

am get a value like ' 15' in a variable what is the easiest method i can follow to strip 15 out (3 Replies)
Discussion started by: anumkoshy
3 Replies

3. Programming

How to trim the white space around a string in C program

I am coding a C program to read a plain text file. There are a lot of blank fields or a string with white spaces. I want to know is there such a function called trim() in C to clean the white space around a string? Or some other way can do this efficiently? Thanks. (18 Replies)
Discussion started by: hxm1303
18 Replies

4. Shell Programming and Scripting

trim spaces in a file

Hi, I'm new to shell programming. Need some help in the following requirement: I have a file origFile.txt with values: origFile.txt .00~ 145416.02~ xyz~ ram kishor .35~ 765.76~ anh reid~ kishna kerry Now each row in the file has value for 4 columns with "~" as... (7 Replies)
Discussion started by: badrimohanty
7 Replies

5. Shell Programming and Scripting

trim spaces and replacing value

Hi, I have a file origFile.txt with values: origFile.txt .00~ 145416.02~ xyz~ ram kishor ~? ~ ~783.9 .35~ 765.76~ anh reid~ kelly woodburg ~nancy ~ ~? Now each row in the file has value for 7 columns with "~" as delimiter. The requirement was i)I need to erase the blank spaces between... (2 Replies)
Discussion started by: badrimohanty
2 Replies

6. Shell Programming and Scripting

(g)awk how to preseve white spaces (FS characters) or read a right subpart of $0?

Hi, I am using gawk (--posix) for extracting some information from something like the following lines (in a text file): sms_snath_hp_C/CORE BUILD PREREQUISITE: total 1556 drwxrwxrwx 2 sn sn 4096 2008-06-27 08:31 ./ drwxrwxrwx 13 sn sn 4096 2009-07-22 14:48 ../ -rwxrwxrwx 1 sn sn ... (14 Replies)
Discussion started by: shri_nath
14 Replies

7. Shell Programming and Scripting

trim spaces in unix for variable

HI Guys I have written a script using awk to split a file based on some identifier and renaming the file based on two values from specific length. ts a fixed width file. When I am trying to fetch the values a = substr($0,11,10) b = substr($0,21,5); i am getting spaces in a and b values .... (6 Replies)
Discussion started by: manish8484
6 Replies

8. Shell Programming and Scripting

awk - trim white space from a field / variable

Hi, Consider the data (FS = |): 1| England |end 2| New Zealand |end 3|Australia|end 4| Some Made Up Country |end 5| West Indies|end I want the output to be (i.e. without the leading and trailing white space from $2) England New Zealand Australia Some Made Up Country West... (4 Replies)
Discussion started by: Storms
4 Replies

9. Shell Programming and Scripting

Trim spaces

All, i am comparing the output of one command to a numberic if ] but my problem is the output of follwoing is but but has some leading columns. I don't have any problme in LINUX and HP-UX. But only in AIX i am getting the leading spaces. I have developed my script on LINUX but when... (4 Replies)
Discussion started by: rcc50886
4 Replies

10. UNIX for Beginners Questions & Answers

Trim trailing spaces from file

I have a file like this. hari,corporationbank,2234356,syndicate ravi,indian bank,4567900000000,indianbank,accese raju,statebank of hyderabad,565866666666666,pause Here each record has different record length and there are blank spaces... (8 Replies)
Discussion started by: kshari8888
8 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 03:44 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy