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
GPM.CONF(5)						      BSD File Formats Manual						       GPM.CONF(5)

NAME
gpm.conf -- startup configuration file for gpm DESCRIPTION
gpm.conf specifies options to be passed to the gpm daemon at start time. It is parsed by the init script, rather than by gpm itself. It comprises variable assignments in Bourne shell syntax: variable=value (with no extra spaces; to embed spaces or other shell metacharacters in values, use quotes as in shell scripting). Blank lines and lines beginning with a hash ("#") are ignored. Settings are implemented by setting flags on the gpm command line; these are documented in gpm(8). The following variable names are speci- fied: device Specifies the device file for your primary mouse. This sets -m. type Specifies the protocol for your primary mouse. This sets -t. device2, type2 The same as device and type, but for your secondary mouse. These set -m and -t after passing -M. If either of these are defined, both must be. responsiveness Specifies the responsiveness for your primary mouse. This sets -r. sample_rate Specifies the sample rate for your primary mouse. This sets -s. repeat_type Enables the gpm repeater and sets the repeater protocol, using the -R flag. Repeat type none or an empty value will disable the repeater. append Any options specified here are appended to the gpm command line. If you use multiple options, you will need to enclose the value in quotes (""). EXAMPLES
A simple gpm.conf file for a PS/2 mouse whose protocol should be autodetected, and which should be repeated in /dev/gpmdata as a serial Mi- crosoft Intellimouse: # Sample gpm.conf device=/dev/psaux type=autops2 repeat_type=ms3 This will cause the daemon to be started as gpm -m /dev/psaux -t autops2 -Rms3. FILES
/etc/gpm.conf SEE ALSO
gpm(8), dpkg-reconfigure(8). dpkg-reconfigure gpm can be used to generate and update the gpm.conf file automatically. Debian 3.0 January 5, 2005 Debian 3.0
All times are GMT -4. The time now is 07:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy