Sponsored Content
Top Forums Shell Programming and Scripting Remove white space at the beginning of lines Post 302231545 by ShawnMilo on Tuesday 2nd of September 2008 02:52:44 PM
Old 09-02-2008
You could pipe it through a Perl one-liner pretty easily.

| perl -pe 's/^\s+//'

Note: This will remove any leading whitespace. If the line is all whitespace, the \s+ will capture the newline character.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Add new lines with a space in beginning

Hi file1.txt contains GigabitEthernet1/1 GigabitEthernet1/2 GigabitEthernet2/2 GigabitEthernet2/4 GigabitEthernet2/14 GigabitEthernet2/16 can anyone show me how to modify it as below. there is a space at the beginning of the next two lines . ie 'no shut' and 'switch..' !... (8 Replies)
Discussion started by: Aejaz
8 Replies

2. UNIX for Dummies Questions & Answers

SED with White Space

Dear Members, Suppose i have a variable test which stores a string as below: test='John drives+++++++++a+++++car' now i want to use sed on the above variable and replace + with a white space, so that i get echo $test should give me 'john drives a car' Between... (1 Reply)
Discussion started by: sandeep_1105
1 Replies

3. Shell Programming and Scripting

Extract lines between 2 strings add white space

I'm trying to extract all the lines between 2 strings (including the lines containing the strings) To make the strings unique I need to include white space if possible. I'm not certain how to do that. sed -n '/ string1 /,/string2/p' infile > outfile & (4 Replies)
Discussion started by: dcfargo
4 Replies

4. Shell Programming and Scripting

How to remove white spaces from the beginning an end of a string in unix?

Suppose, I have a variable var=" name is ". I want to remove the blank spaces from the begining and endonly, not from the entire string. So, that the variable/string looks like following var="name is". Please look after the issue. (3 Replies)
Discussion started by: mady135
3 Replies

5. Shell Programming and Scripting

remove white space from specific columns in text file

Hello i have a text file like this: 1 AB AC AD EE 2 WE TR YT WW 3 AS UY RF YT the file is bigger , but that's an example of the data what i want to do is to merge all columns together except the first one, it will become like this : 1 ABACADEE 2 WETRYTWW 3 ASUYRFYT (8 Replies)
Discussion started by: shelladdict
8 Replies

6. Shell Programming and Scripting

Remove unwanted white space

Hi, I have a very big file 25GB with information present in it like $ head ind_stats update index statistics pfirm001.dbo.Office using 200 values go ... (11 Replies)
Discussion started by: sam05121988
11 Replies

7. Shell Programming and Scripting

Remove certain lines from file based on start of line except beginning and ending

Hi, I have multiple large files which consist of the below format: I am trying to write an awk or sed script to remove all occurrences of the 00 record except the first and remove all of the 80 records except the last one. Any help would be greatly appreciated. (10 Replies)
Discussion started by: nwalsh88
10 Replies

8. Shell Programming and Scripting

Remove white space and duplicate headers

I have a file called "dsout" with empty rows and duplicate headers. DATE TIME TOTAL_GB USED_GB %USED --------- -------- ---------- ---------- ---------- 03/05/013 12:34 PM 3151.24316 2331.56653 73.988785 ... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

9. Shell Programming and Scripting

Add white space

hi guys how can i add spacein file name with sed if strings have no space around dash input 19-20 ( 18-19 ) ABC-EFG output after add white space 19 - 20 (18 - 19 ) ABC - EFG thx in advance (2 Replies)
Discussion started by: mhs
2 Replies

10. Shell Programming and Scripting

Remove of white space when you have multiple column

i have file in which i want to remove white space from each column where ever it exist there is white space at the end of line. i know how to remove white space if i have only 1 column, but i have multiple columns and white space can be in any column. sed 's/ *$//' file ath-miRf10005-akr... (5 Replies)
Discussion started by: mirwasim
5 Replies
XUPDATE(1p)						User Contributed Perl Documentation					       XUPDATE(1p)

NAME
xupdate - Process XUpdate commands over an XML document SYNOPSIS
xupdate [options] <xupdate-file> <input-file> Options: -u | --usage print brief help on usage -h | --help print documentation -n | --namespace prefix=namespace-uri associate a namespace with a prefix for use in XPath selections in XUpdate file (this option may occur several times) -k | --keep-ws preserve whitespace in the XUpdate file -s | --strip-ws strip ignorable whitespace from the input file -V | --version print current version and revision -i | --indent indent the output XML -j | --extra-indent like -i, but also adds a leading and a trailing linebreak to every text node. but also put an extra newline after every start-tag and before every end-tag OPTIONS
--usage Print a brief help message on usage and exits. --help Prints the manual page and exits. --namespace prefix=namespace-uri Associate a namespace with a prefix. The prefix may be used in the XPath selections in the XUpdate file to address nodes of the source document that belong to the given namespace. This is especially useful for mapping the default namespace to a prefix because XPath by definition doesn't honour default namespaces. This option may occur several times. --keep-ws Preserves any whitespace in XUpdate file. The default behaviour is to remove all ignorable whitespace and any leading or trailing whitespace in all XUpdate command elements in the XUpdate file. --strip-ws Remove "ignorable" whitespace from the input file. The default behaviour is to keep any whitespace unless the --extra-indent (-j) option is used. Note that the whitespace being present or not may affect results returned by some XPath expressions (such as /foo/bar/text()[2]). --version Print version and revision number of This program command and version number of XML::XUpdate library used. --indent Indent the resulting document on output. --extra-indent Indent the resulting document on output as --indent, but also add a leading and a trailing linebreak to every text node. --debug Print some debugging information about commands being applied. DESCRIPTION
This program will parse the given XUpdate file and the input file and print the input file updated accordingly. XUpdate file format is described in XUpdate Working Draft from 2000-09-14 (http://www.xmldb.org/xupdate/xupdate-wd.html). AUTHOR
Petr Pajas, pajas@matfyz.cz COPYRIGHT
Copyright 2002-2003 Petr Pajas, All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-08-02 XUPDATE(1p)
All times are GMT -4. The time now is 04:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy