12-17-2008
remove whitespace
Thanks vgersh99.
I got this from another area of the forum (I looked first but not good enough). This is what I needed.
sed -e 's/[ ]*,[ ]*/,/g' -e 's/^[ ]*//' -e 's/[ ]*$//' file1
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I know removing whitespaces I can found so many threads to read how it works and i did it, but my problem isn't solved...
I have in my script a variable $1 which can contains a text like " Channel ".
No I want to check if $1 contains the word Channel, but I don't know how many... (4 Replies)
Discussion started by: bensky
4 Replies
2. Shell Programming and Scripting
I'm trying to find a command that will trim the white space off a string.
e.g.
$str = " stuf "
$str = trim ( $str )
echo $str // ouput would just be stuf
Thanks, Mark (4 Replies)
Discussion started by: msteudel
4 Replies
3. Shell Programming and Scripting
I'm trying to remove the whitespace at the end of each line of a text file in ksh.
Im using
sed s/ $//g' file1.txt > file2.txt
It's not working. Any clues? (3 Replies)
Discussion started by: b.hamilton
3 Replies
4. Shell Programming and Scripting
I have a file that I am spliting and parsing, if data starts with an N/n toos it (which works) but I want it to also see if the data is blank and toss it.
What I have does not toss the blank space for dduck????
here is the data file and code I have.....
efudd 7546
bbunny N0542
tdevil... (3 Replies)
Discussion started by: theninja
3 Replies
5. Shell Programming and Scripting
Hi
Following is an example line.
echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:"
I want it's output to be
200
However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies
6. Shell Programming and Scripting
Hello I am working aon script, that tells me how many users or on the system when i run it.
The script is
#!/bin/bash
w | cut -f 1 -d ' ' |sort -u | wc -l
When ran it shows 16 users including myself and a line of white space.
I was wondering what I need to add to remove my user... (2 Replies)
Discussion started by: mosdojaf
2 Replies
7. Shell Programming and Scripting
I have a 13 number string, some whitespace, and then /mp3.
I need to join them. Everyline that I need this for begins with "cd" (without the quotes).
What it looks like now:
cd media/Audio/WAVE/9781933976334 /mp3 What I want my output to be:
cd media/Audio/WAVE/9781933976334/mp3 The 13... (7 Replies)
Discussion started by: glev2005
7 Replies
8. Shell Programming and Scripting
This is my file
.........hostname.............this is hostname
.........alias...................alias name
Remark use dot(.) instead of whitespace B'cuz this forum not allow to use more whitespace.
---------------------------------------
I sperate by whitespace not work.
awk 'BEGIN {FS=" "}... (4 Replies)
Discussion started by: cyberking
4 Replies
9. Shell Programming and Scripting
I have a file that looks like this:
102| #2 X 1/4-INCH| 30188| EA| FTW| A| NOT SERIAL TRACKING| NOT LOT TRACKING| TRUE| #2 X 1/4-INCH
102| #2 X 1/4-INCH| 30188| EA| VPS| A| NOT SERIAL TRACKING| NOT LOT TRACKING| TRUE| #2 X 1/4-INCH
102| #6 X 1/2"| ... (2 Replies)
Discussion started by: djehresmann
2 Replies
10. UNIX for Dummies Questions & Answers
Hi again
I have an xml file and want to remove the leading white space as it causes me issues later in my script
I see sed is possible but cant seem to get it to work
I tried
sed 's/^ *//' file.xml
output
<xn:VsDataContainer id="1U104799" modifier="update">
... (10 Replies)
Discussion started by: aniquebmx
10 Replies
LEARN ABOUT DEBIAN
javascript::minifier::xs
JavaScript::Minifier::XS(3pm) User Contributed Perl Documentation JavaScript::Minifier::XS(3pm)
NAME
JavaScript::Minifier::XS - XS based JavaScript minifier
SYNOPSIS
use JavaScript::Minifier::XS qw(minify);
$minified = minify($js);
DESCRIPTION
"JavaScript::Minifier::XS" is a JavaScript "minifier"; its designed to remove un-necessary whitespace and comments from JavaScript files,
which also not breaking the JavaScript.
"JavaScript::Minifier::XS" is similar in function to "JavaScript::Minifier", but is substantially faster as its written in XS and not just
pure Perl.
METHODS
minify($js)
Minifies the given $js, returning the minified JavaScript back to the caller.
HOW IT WORKS
"JavaScript::Minifier::XS" minifies the JavaScript by removing un-necessary whitespace from JavaScript documents. Comments (both block and
line) are also removed, except when (a) they contain the word "copyright" in them, or (b) they're needed to implement "IE Conditional
Compilation".
Internally, the minification process is done by taking multiple passes through the JavaScript document:
Pass 1: Tokenize
First, we go through and parse the JavaScript document into a series of tokens internally. The tokenizing process does not check to make
sure you've got syntactically valid JavaScript, it just breaks up the text into a stream of tokens suitable for processing by the
subsequent stages.
Pass 2: Collapse
We then march through the token list and collapse certain tokens down to their smallest possible representation. If they're still included
in the final results we only want to include them at their shortest.
Whitespace
Runs of multiple whitespace characters are reduced down to a single whitespace character. If the whitespace contains any "end of line"
(EOL) characters, then the end result is the first EOL character encountered. Otherwise, the result is the first whitespace character
in the run.
Pass 3: Pruning
We then go back through the token list and prune and remove un-necessary tokens.
Whitespace
Wherever possible, whitespace is removed; before+after comment blocks, and before+after various symbols/sigils.
Comments
Comments that are either (a) IE conditional compilation comments, or that (b) contain the word "copyright" in them are preserved. All
other comments (line and block) are removed.
Everything else
We keep everything else; identifiers, quoted literal strings, symbols/sigils, etc.
Pass 4: Re-assembly
Lastly, we go back through the token list and re-assemble it all back into a single JavaScript string, which is then returned back to the
caller.
AUTHOR
Graham TerMarsch (cpan@howlingfrog.com)
REPORTING BUGS
Please report bugs via RT (<http://rt.cpan.org/Dist/Display.html?Queue=JavaScript::Minifier::XS>), and be sure to include the JavaScript
that you're having troubles minifying.
COPYRIGHT
Copyright (C) 2007-2008, Graham TerMarsch. All Rights Reserved.
This is free software; you can redistribute it and/or modify it under the same license as Perl itself.
SEE ALSO
"JavaScript::Minifier".
perl v5.14.2 2011-11-15 JavaScript::Minifier::XS(3pm)