Sponsored Content
Top Forums Shell Programming and Scripting Remove spaces from between words that are in a field Post 302833077 by vidyadhar85 on Tuesday 16th of July 2013 07:11:20 AM
Old 07-16-2013
u can.. but bit messy though

Code:
 
awk '{v=substr($0,45,22);sub(/[ ]+/," ",v);print substr($0,0,44) v substr($0,68)}' filename

This User Gave Thanks to vidyadhar85 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Retaining spaces between words

Retaining Spaces within a word -------------------------------------------------------------------------------- Hi Experts, I have a 2 GB flat file which have unicode field, some of them are blanks and its size is 4000 character. In the existing system SED command removes the spaces.... (7 Replies)
Discussion started by: RcR
7 Replies

2. Shell Programming and Scripting

Remove spaces from first field, and write entire contents into other text file

Hi all, I have searched and found various threads about removing spaces from a field within a text file. Unfortunately, I have not found exactly what I'm looking for, nor am I adept enough to modify what I've found into what I need. I use the following command to remove the first line... (3 Replies)
Discussion started by: carriehoff
3 Replies

3. Programming

Counting characters, words, spaces, punctuations, etc.

I am very new to C programming. How could I write a C program that could count the characters, words, spaces, and punctuations in a text file? Any help will be really appreciated. I am doing this as part of my C learning exercise. Thanks, Ajay (4 Replies)
Discussion started by: ajay41aj
4 Replies

4. Shell Programming and Scripting

spaces in array field

I have a file, names(i) where each entry is 'first last' name. 'cat names' is fine. But in a shell script >for file in $(cat names) > do > echo $file > done the first and last name appear on 2 lines. I have tried escaping and quoting the space but to no avail. The names are to be... (4 Replies)
Discussion started by: chuckmg
4 Replies

5. Shell Programming and Scripting

Trying to use sed to remove the value of one field from another field

I'm trying to use sed to remove the value of one field from another field. For example: cat inputfile 123|ABC|Generic_Textjoe@yahoo.com|joe@yahoo.com|DEF 456|GHI|Other_recordjohn@msn.com|john@msn.com|JKL 789|MNO|No_Email_On_This_One|smith@gmail.com|PQR I would like to remove the email... (2 Replies)
Discussion started by: bribri87
2 Replies

6. Shell Programming and Scripting

Help with removal of blank spaces from the second field!

Hi everyone.. I'm trying to eliminate multiple whitespaces from a file.. I must make use of shell script to eliminate whitespaces.. Take a look at the sample file 1 int main() 2 { 3 int a,b; 4 printf("Enter the values of a and b"); 5 scanf("%d%d",&a,&b); 6 if(a>b) ... (6 Replies)
Discussion started by: abk07
6 Replies

7. Shell Programming and Scripting

Insert varying length spaces between words

Hey all, Fist post, so be kind... I have written an expect script which logs into a terminal and gathers several screens of information. Unfortunately the log file gives me all the special escape and control characters from the terminal. I am hoping to use a combination of shell scripting, sed,... (1 Reply)
Discussion started by: mpacer
1 Replies

8. UNIX for Dummies Questions & Answers

Removing spaces in the second field alone

Consider my input string as "abc|b f g|bj gy" I am expecting the output as "abc|bfg|bj gy". Please let me know how to achieve this in unix? Thanks (8 Replies)
Discussion started by: pandeesh
8 Replies

9. Shell Programming and Scripting

Concatenating words without spaces.

Hi All, I have written a C program to solve this problem but I am eager to know whether the same output can be obtained using sed or awk? This is the input: star ferry computer symbol prime time This is the output: starferry ferrycomputer computersymbol symbolprime primetime (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

10. Shell Programming and Scripting

Grep words with spaces and save the output

I have a file that contains the schedule for a tournament with 41 teams. The team names have spaces in them. I would like to search for each teams schedule and then save that to that teams file For example Team name: "Team Two" I would like to search for all the games for "Team Two" and... (8 Replies)
Discussion started by: knijjar
8 Replies
wc(1)							      General Commands Manual							     wc(1)

NAME
wc - count words, lines, and bytes or characters in a file SYNOPSIS
[file]... DESCRIPTION
The command counts lines, words, and bytes or characters in the named files, or in the standard input if no file names are specified. It also keeps a total count for all named files. A word is a string of characters delimited by spaces, tabs, or newlines. Options recognizes the following options: Report the number of bytes in each input file. Report the number of newline characters in each input file. Report the number of characters in each input file. Report the number of words in each input file. The and options are mutually exclusive. Otherwise, the and or options can be used in any combination to specify that a subset of lines, words, and bytes or characters are to be reported. When any option is specified, reports only the information requested. If no option is specified, the default output is When a file is specified on the command line, its name is printed along with the counts. Standard Output By default, the standard output contains an entry for each input file in the form: newlines words bytes file If the option is specified, the number of characters replaces the bytes field in this format. If any option is specified, the fields for the unspecified options are omitted. If no file operand is specified, neither the file name nor the preceding blank character is written. If more than one file operand is specified, an additional line is written at the end of the output, of the same format as the other lines, except that the word (in the POSIX locale) is written instead of a file name and the total of each column is written as appropriate. Under UNIX Standard environment, a word is a string of characters delimited by spaces, tabs, newline, carriage-return, vertical tab, or form-feed. RETURN VALUE
exits with one of the following values: Successful completion. An error occurred. EXTERNAL INFLUENCES
For information about the UNIX Standard environment, see standards(5). Environment Variables determines the range of graphics and space characters, and the interpretation of text as single- and/or multibyte characters. determines the language in which messages are displayed. If or is not specified in the environment or is null, they default to the value of If is not specified or is null, it defaults to (see lang(5)). If any internationalization variable contains an invalid setting, they all default to See environ(5). International Code Set Support Single- and multibyte character code sets are supported. with a newline character, the count will be off by one. WARNINGS
The command counts the number of newlines to determine the line count. If a text file has a final line that is not terminated with a new- line character, the count will be off by one. EXAMPLES
Print the number of words and characters in The following is printed when the above command is executed: where words is the number of words and chars is the number of characters in SEE ALSO
standards(5). STANDARDS CONFORMANCE
wc(1)
All times are GMT -4. The time now is 11:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy