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
TABFUNC(1)						      General Commands Manual							TABFUNC(1)

NAME
tabfunc - convert table to functions for rcalc, etc. SYNOPSIS
tabfunc [ -i ] func1 [func2 ..] DESCRIPTION
Tabfunc reads a table of numbers from the standard input and converts it to an expression suitable for icalc(1), rcalc(1) and their cousins. The input must consist of a M x N matrix of real numbers, with exactly one row per line. The number of columns must always be the same in each line, separated by whitespace and/or commas, with no missing values. The first column is always the independent variable, whose value indexes all of the other elements. This value does not need to be evenly spaced, but it must be either monotonically increas- ing or monotonically decreasing. (I.e. it cannot go up and then down, or down and then up.) Maximum input line width is 4096 characters and the maximum number of data rows is 1024. Input lines not beginning with a numerical value will be silently ignored. The command-line arguments given to tabfunc are the names to be assigned to each column. Tabfunc then produces a single function for each column given. If there are some columns which should be skipped, the dummy name "0" may be given instead of a valid identifier. (It is not necessary to specify a dummy name for extra columns at the end of the matrix.) The -i option causes tabfunc to produce a description that will interpolate values in between those given for the independent variable on the input. EXAMPLE
To convert a small data table and feed it to rcalc for some calculation: rcalc -e `tabfunc f1 f2 < table.dat` -f com.cal AUTHOR
Greg Ward SEE ALSO
cnt(1), icalc(1), neaten(1), rcalc(1), rlam(1), total(1) RADIANCE
10/8/97 TABFUNC(1)
All times are GMT -4. The time now is 06:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy