Sponsored Content
Top Forums Shell Programming and Scripting Removing leading and trailing spaces only in PERL Post 302304041 by pludi on Saturday 4th of April 2009 03:14:07 PM
Old 04-04-2009
Option 1:
Code:
$data =~ s/\|\s+/g;
$data =~ s/\s+\|/g;

Option 2:
Code:
$data = join '|', map { s/\s+$/; s/^\s+/; } split /|/, $data;

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

removing trailing spaces of a particular column in a file

Hi, I am currently confused. Suppose I have a file something like the one below. 4299|raj Telecommunications|12||||| 4302|anjali International Ltd.|86|ritchie||dong|(000)2890 9993 |(222)4881 3689 4305|フィデュシアリ・ト-スト・インター...ショ...ル投資顧問株式会社 |112||||01-9211-1931 |08-3677-1985 Now... (2 Replies)
Discussion started by: rooh
2 Replies

2. Shell Programming and Scripting

Leading and Trailing Spaces

Hi, how to i remove leading and trailing spaces from a line? the spaces can be behind or in front of any field or line example of a line in the input data: Amy Reds , 100 , /bin/sh how to i get it to be: Amy Read,100,/bin/sh i saw something on this on the Man pages for AWK... (7 Replies)
Discussion started by: sleepster
7 Replies

3. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies

4. UNIX for Dummies Questions & Answers

Removing leading and trailing spaces of data between the tags in xml.

I am having xml document as below. <transactionid> 00 </transactionid> <tracknumber> 0 </tracknumber> <key> N/A </key> But the data contains leading and trailing spaces between the tags. Please let me know how can i remove these leading and trailing spaces between the tags.... (2 Replies)
Discussion started by: jhmr7
2 Replies

5. Shell Programming and Scripting

Removing trailing spaces from delimited files

Hi All I have a file of the following format (delimited by |) this is field 1 | field 2 (lots of blank spaces) | field 3 (lots of blank space) | field 1 | more text (lots of blank spaces) | dhjdsk | Is there a way I can remove... (6 Replies)
Discussion started by: djkane
6 Replies

6. Shell Programming and Scripting

remove trailing and leading spaces using tr command

Dear All, can you please advice how do i remove trailing and leading spaces from a pipe-delimited file using "tr" command the below cmd, i tried removed all spaces tr -d ' '<s1.txt>s2.txt1 Many thx Suresh (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

7. Shell Programming and Scripting

Removing leading spaces from the variable value.

Hi All, I am trying to replace the value of a xml tag with a new one. But, the existing value in the xml contain leading spaces and I tried to remove that with different sed commands but all in vain. For replacing the value I wrote the command in BOLD letters below: bash-3.00$... (3 Replies)
Discussion started by: khedu
3 Replies

8. UNIX for Dummies Questions & Answers

Need help removing leading spaces from one field in comma seperated file

Using awk or sed, I'd like to remove leading spaces after a comma and before a right justified number in field 6. Sounds simple but I can't find a solution. Each field's formatting must stay intact. Input: 40,123456-02,160,05/24/2012,02/13/1977, 10699.15,0 Output:... (5 Replies)
Discussion started by: Scottie1954
5 Replies

9. Shell Programming and Scripting

Remove leading and trailing spaces from a file

Hi, I am trying to remove leading and trailing spaces from a file using awk but somehow I have not been able to do it. Here is the data that I want to trim. 07/12/2017 15:55:00 |entinfdev |AD ping Time ms | .474| 1.41| .581|green |flat... (9 Replies)
Discussion started by: svajhala
9 Replies

10. Shell Programming and Scripting

How to remove leading and trailing spaces for variable in shell script?

Hi I have variable named tablename. The value to tablename variable has leading and trailing white spaces. How to remove the leading and training white spaces and write the value of the tablename without space to a file using shell script. ( for e.g. tablename= yyy ) INPUT ... (10 Replies)
Discussion started by: pottic
10 Replies
ASLINK(1)						      General Commands Manual							 ASLINK(1)

NAME
SDLD - companion linker for the ASxxxx assemblers. SYNOPSIS
sdld [-Options] [-Option with arg] file sdld [-Options] [-Option with arg] outfile file1 [file2 ...] sdldgb [-Options] [-Option with arg] file sdldgb [-Options] [-Option with arg] outfile file1 [file2 ...] sdldz80 [-Options] [-Option with arg] file sdldz80 [-Options] [-Option with arg] outfile file1 [file2 ...] sdld6808 [-Options] [-Option with arg] file sdld6808 [-Options] [-Option with arg] outfile file1 [file2 ...] WARNING
The information in this man page is an extract from the full documentation of SDCC, and is limited to the meaning of the options. For complete and current documentation, refer to the ASxxxx Cross Assembler Documentation, available in /usr/share/doc/sdcc-doc/aslink. DESCRIPTION
The ASLINK is general relocating companion linker for the ASxxx assemblers. MCS51 family is supported by sdld. Z80family is supported by sdldz80. GBZ80 (GameBoy Z80-like CPU) is supported by sdldgb. Motorola 6808 family is supported by sdld6808. OPTIONS
The linker may run in the command line mode or command file modes. The allowed startup linker commands are: -c/-f command line / command file modes -p/-n enable/disable echo file.lnk input to stdout If command line mode is selected, all linker commands come from stdin, if the command file mode is selected the commands are input from the specified file (extension must be .lnk). After invoking the linker the valid options are: Libraries -k library directory path (one definition per line) This specifies one possible path to an object library. More than one path is allowed. -l library file specification (one definition per line) This specifies a possible library file. More than one file is allowed. Relocation -b area base address = expression (one definition per line) This specifies an area base address where the expression may contain constants and/or defined symbols from the linked files. -g global symbol = expression (one definition per line) This specifies the value for the symbol where the expression may contain constants and/or defined symbols from the linked files. Map format: -m Generate a map file (file.map). This file contains a list of the symbols (by area) with absolute addresses, sizes of linked areas, and other linking information. -w Specifies that a wide listing format be used for the map file. -x Hexidecimal (default). -d Decimal. -q Octal. Output: -i Intel Hex (file.ihx) image output file. -s Motorola S19 (file.s19) image output file. -j Produce NoICE debug as file (file.noi) -z Produce SDCdb debug as file (file.cdb). Lists: -u Generate an updated listing file (file.rst) derived from the relocated addresses and data from the linker. Miscellaneous: -a [iram-size] Check for internal RAM overflow. -v [xram-size] Check for external RAM overflow. -w [code-size] Check for code overflow. -y Generate memory usage summary file (file.mem). -Y Pack internal ram. -A [stack-size] Allocate space for stack. End: -e or null line, terminates input to the linker. fileN Files to be linked. Files may be on the same line as the above options or on a separate line(s) one file per line or multiple files separated by spaces or tabs. SEE ALSO
sdcc(1), asxxxx(1), sdldz80(1), sdldgb(1), sdld6808(1). AUTHOR
This manual page was written by Aurelien Jarno <aurel32@debian.org>, for the Debian GNU/Linux system (but may be used by others). ASLINK(1)
All times are GMT -4. The time now is 04:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy