Sponsored Content
Top Forums Shell Programming and Scripting csh script for deleting extra spaces in text file Post 302297133 by hertingm on Thursday 12th of March 2009 02:43:27 PM
Old 03-12-2009
csh script for deleting extra spaces in text file

I am new to scripting and I needed to know if there would be an easy way to delete extra spaces in a text file. I have a file with three rows with 22 numbers each, but there is extra spaces between the numbers when it gets output by this program AFNI that I am using. What script would help delete the extra spaces so that there is only one space between numbers? The thing is, the numbers aren't all evenly spaced in the rows....

Thanks in advance...

Megan

Below is an example of what I have, and what I would like....

I have:
0 0 0.999967 6.99001e-06 -0.0311094 0.854128 0.836092 0.834233 -0.85582 0.823927 0.550543 0.465525 0.515718 0.392239 -0.479025 -0.391751 -0.513501 -0.467562 -0.552394 -0.110216 0.110064 0.0316397
0 0 -0.00581784 -0.963206 0.608888 0.520062 0.177423 -0.428004 0.439036 0.162573 0.612435 0.883944 0.704232 0.291954 0.247972 0.710596 0.857074 0.726207 0.217247 -0.0147384 0.52374 0.936388
0 0 -0.00566925 0.268765 -0.792646 0.000969838 -0.519105 -0.347661 -0.273532 0.542876 0.567297 0.0439296 -0.487947 -0.872302 0.842048 0.584452 0.0417219 -0.503993 -0.804776 -0.993798 0.844738 0.349539

I'd like:
0 0 0.999967 6.99001e-06 -0.0311094 0.854128 0.836092 0.834233 -0.85582 0.823927 0.550543 0.465525 0.515718 0.392239 -0.479025 -0.391751 -0.513501 -0.467562 -0.552394 -0.110216 0.110064 0.0316397
0 0 -0.00581784 -0.963206 0.608888 0.520062 0.177423 -0.428004 0.439036 0.162573 0.612435 0.883944 0.704232 0.291954 0.247972 0.710596 0.857074 0.726207 0.217247 -0.0147384 0.52374 0.936388
0 0 -0.00566925 0.268765 -0.792646 0.000969838 -0.519105 -0.347661 -0.273532 0.542876 0.567297 0.0439296 -0.487947 -0.872302 0.842048 0.584452 0.0417219 -0.503993 -0.804776 -0.993798 0.844738 0.349539
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting end line spaces for along file

How can i clear all space characteres for a long file at the end of each line? (3 Replies)
Discussion started by: osymad
3 Replies

2. Shell Programming and Scripting

how to insert a extra line in a text file

how to insert a extra line in a text file using a sh command iam trying to think of a way to add a extra line but without deleting the whole text do anyone have any ideas (2 Replies)
Discussion started by: bhaviknp
2 Replies

3. Shell Programming and Scripting

exporting number into .csv file in text form (no other extra charc) from shell script

I have written a k shell program which is executing a sql and exporting data in numeric form like 0412323444 into .csv file. the problem i am facing is that , the data is coming in excel formatted in scientific form like 4.1+E08,while my requirement is to store data as such 0412323444 in excel ( no... (5 Replies)
Discussion started by: Deepak_Rastogi
5 Replies

4. Shell Programming and Scripting

how can i pass parameter with spaces to csh script

Hello all i need to pass to my shell script parameter that looks like "2 3 3" inside the script i need to use this string that looks like this "2 3 3" but when i try to print the script im getting syntax error , this is my script : set s = $1 echo $s (1 Reply)
Discussion started by: umen
1 Replies

5. UNIX for Dummies Questions & Answers

deleting white spaces in a file

Hello Guys, I am a newbie to unix. I am having a requirement. Please help me for finding a solution for this, I am having a file as mentioned below: $ cat shank ackca acackac akcajc akcjkcja akcj ckcklc I want to delete all the white spaces in this file, I tried... (2 Replies)
Discussion started by: mraghunandanan
2 Replies

6. Shell Programming and Scripting

Deleting lines that contain spaces in a txt file

I need some help deleting lines in a file that contain spaces. Im sure awk or sed will work but i dont know much about those commands. Any help is appreciated :D (7 Replies)
Discussion started by: r04dw4rri0r
7 Replies

7. Shell Programming and Scripting

clear extra spaces and tabs in a file

Any help appreciated Thanks sample input: > (extra spaces&tabs in here) test1 (extra spaces&tabs in here) 123.123.123.123 (extra spaces&tabs in here) abc (extra spaces&tabs in here) 123 --- < (extra spaces&tabs in... (3 Replies)
Discussion started by: goofist
3 Replies

8. Shell Programming and Scripting

How can I stop the unix script from trimming extra spaces?

I have a file which contains certain records about users. the row length is always fixed to 205 characters. Now I want to read each record line from the file, substring some portion out of it and put into another file. But I have observed that my script is trimming the extra spaces I have used for... (4 Replies)
Discussion started by: Pramit
4 Replies

9. UNIX Desktop Questions & Answers

To remove the extra spaces at the end of each line in a file

I have a file of about 10k records and eace line is having an extra space of 5 byte at the end.. Iwant to remove the extra spaces at the end of each line.. Can someone please help me out.. I tried using sed command and its not working... can someone please help me out. (3 Replies)
Discussion started by: rammohan
3 Replies

10. Shell Programming and Scripting

Read variables from a text file for use in csh script

Hello, I have a text file (say, declarevars.txt) that contains multiple lines that are essentially meant to be variable declarations: set arr1 = (var1a var1b var1c) set arr2 = (var2a var2b var2c) . . . I want to be able to read this text file within a csh (sorry) script and have that... (2 Replies)
Discussion started by: arjaydj
2 Replies
CGI::Pretty(3)						User Contributed Perl Documentation					    CGI::Pretty(3)

NAME
CGI::Pretty - module to produce nicely formatted HTML code SYNOPSIS
use CGI::Pretty qw( :html3 ); # Print a table with a single data element print table( TR( td( "foo" ) ) ); DESCRIPTION
CGI::Pretty is a module that derives from CGI. It's sole function is to allow users of CGI to output nicely formatted HTML code. When using the CGI module, the following code: print table( TR( td( "foo" ) ) ); produces the following output: <TABLE><TR><TD>foo</TD></TR></TABLE> If a user were to create a table consisting of many rows and many columns, the resultant HTML code would be quite difficult to read since it has no carriage returns or indentation. CGI::Pretty fixes this problem. What it does is add a carriage return and indentation to the HTML code so that one can easily read it. print table( TR( td( "foo" ) ) ); now produces the following output: <TABLE> <TR> <TD>foo</TD> </TR> </TABLE> Recommendation for when to use CGI::Pretty CGI::Pretty is far slower than using CGI.pm directly. A benchmark showed that it could be about 10 times slower. Adding newlines and spaces may alter the rendered appearance of HTML. Also, the extra newlines and spaces also make the file size larger, making the files take longer to download. With all those considerations, it is recommended that CGI::Pretty be used primarily for debugging. Tags that won't be formatted The following tags are not formatted: <a>, <pre>, <code>, <script>, <textarea>, and <td>. If these tags were formatted, the user would see the extra indentation on the web browser causing the page to look different than what would be expected. If you wish to add more tags to the list of tags that are not to be touched, push them onto the @AS_IS array: push @CGI::Pretty::AS_IS,qw(XMP); Customizing the Indenting If you wish to have your own personal style of indenting, you can change the $INDENT variable: $CGI::Pretty::INDENT = " "; would cause the indents to be two tabs. Similarly, if you wish to have more space between lines, you may change the $LINEBREAK variable: $CGI::Pretty::LINEBREAK = " "; would create two carriage returns between lines. If you decide you want to use the regular CGI indenting, you can easily do the following: $CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = ""; AUTHOR
Brian Paulsen <Brian@ThePaulsens.com>, with minor modifications by Lincoln Stein <lstein@cshl.org> for incorporation into the CGI.pm distribution. Copyright 1999, Brian Paulsen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Bug reports and comments to Brian@ThePaulsens.com. You can also write to lstein@cshl.org, but this code looks pretty hairy to me and I'm not sure I understand it! SEE ALSO
CGI perl v5.16.3 2011-01-24 CGI::Pretty(3)
All times are GMT -4. The time now is 12:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy