Sponsored Content
Top Forums Shell Programming and Scripting replace spaces/tabs with delimiter | Post 302511227 by alister on Wednesday 6th of April 2011 08:36:06 AM
Old 04-06-2011
Code:
printf '%s\n' '1,$s/[<space><tab>]/|/g' w q | ed -s file >/dev/null

If you like living dangerously (although I wouldn't recommend it):
Code:
(rm file; sed 's/[<space><tab>]/|/g' > file) < file

If using the C/POSIX locale, you can use [[:blank:]] instead of [<space><tab>].

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting tabs in to spaces.

Hi! I'm using SunOS 5.7 w/ Bash 2.01. Currently, I'm working on a script that will make it possible to find textfiles which match certain criteria. While I write this message, I had some brainfarts, found the answer myself :D and the question I had in mind is now no longer the question I... (3 Replies)
Discussion started by: indo1144
3 Replies

2. Shell Programming and Scripting

replacing tabs to spaces from files

hi, I have some 50 C files in which for indentation of code some devlopers used tabs, but we dont want any tab used for indentation. I have following 2 need. 1) find tabs from all 50 files (which are in one directory ) 2) replace them with 4 spaces. Thanks Rishi (6 Replies)
Discussion started by: rishir
6 Replies

3. Shell Programming and Scripting

spaces or Tabs?

When formatting a script let's say for instance the following: case ${choice} in 1) vi ${tmp1}.tmp # overwrite the tmp1 var with any user changes cp ${tmp1}.tmp ${tmp1} ;; ... (2 Replies)
Discussion started by: llsmr777
2 Replies

4. UNIX for Dummies Questions & Answers

Problem with White spaces and tabs

Hi All, I am facing issues converting white spaces and tabs together in a file I am reading. Here is the command I am trying: tr -s ' '@ | sort -t@ +1n filename I guess the problem is that it is not converting the tabs to another delimiter. Also, I am supposed to accomplish this only using... (5 Replies)
Discussion started by: sh_kk
5 Replies

5. 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

6. Shell Programming and Scripting

Replacing tabs with spaces

I want my program to replace tabs with spaces.1tab=4spaces.When i write aa(tab)aaa(tab)(tab)a(tab) it must show me aaxxaaaxxxxxaxxx. I think that my program works corectly but when a write aaa(tab)a it must show aaaxa but it is aaaxxxxxa.Please for help!!! That is my code: #include <stdio.h> ... (3 Replies)
Discussion started by: marto1914
3 Replies

7. Shell Programming and Scripting

spaces to tabs - group with IP

hi buddies; i have a file.txt: Note: All the seperators are SPACE. 192.168.1.1 ParameterObject=1 Speech 1 ParameterObject=2 Speech 1 192.168.1.1 ParamFunction=1 UserID 1 (DEACTIVATED) Sector=1,Device=2,Unit=3 DeviceId 1 192.168.1.1 FeederCable=2B ... (18 Replies)
Discussion started by: gc_sw
18 Replies

8. Shell Programming and Scripting

Remove spaces / tabs from variable in script

I want to remove extra spaces from variable in aix script. We retrieve the data from oracle database and then print the values. We have a value on 90th position. When we execute the query on sqlplus it shows the length of 90th position as 3, but when we use the same query in aix script it shows... (5 Replies)
Discussion started by: lodhi1978
5 Replies

9. UNIX for Advanced & Expert Users

Vimrc creating tabs instead of spaces

I'm having trouble getting my vimrc to work the way I want it. For some reason after I hit enter it is creating tabs instead of spaces like I would expect. Here is an example of what I am talking about. $ = newline, ^I = tab. On the line of struct EDGETAG* q; I hit enter and it created a tab... (2 Replies)
Discussion started by: cokedude
2 Replies

10. Shell Programming and Scripting

[Solved] Insert tabs as delimiter

Hello all, I have an unstructured file with space as delimiter , which I want to structure. The output file should actually have only 5 columns with tab as delimiter. The 4th column can have only 3 values ( biological_process , cellular_component , molecular_function ) Here is how the... (12 Replies)
Discussion started by: ritakadm
12 Replies
iswalpha(3C)						   Standard C Library Functions 					      iswalpha(3C)

NAME
iswalpha, isenglish, isideogram, isnumber, isphonogram, isspecial, iswalnum, iswascii, iswblank, iswcntrl, iswdigit, iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit - wide-character code classification functions SYNOPSIS
#include <wchar.h> #include <wctype.h> int iswalpha(wint_t wc); int isenglish(wint_t wc); int isideogram(wint_t wc); int isnumber(wint_t wc); int isphonogram(wint_t wc); int isspecial(wint_t wc); int iswalnum(wint_t wc); int iswascii(wint_t wc); int iswblank(wint_t wc); int iswcntrl(wint_t wc); int iswdigit(wint_t wc); int iswgraph(wint_t wc); int iswlower(wint_t wc); int iswprint(wint_t wc); int iswpunct(wint_t wc); int iswspace(wint_t wc); int iswupper(wint_t wc); int iswxdigit(wint_t wc); DESCRIPTION
These functions test whether wc is a wide-character code representing a character of a particular class defined in the LC_CTYPE category of the current locale. In all cases, wc is a wint_t, the value of which must be a wide-character code corresponding to a valid character in the current locale or must equal the value of the macro WEOF. If the argument has any other values, the behavior is undefined. iswalpha(wc) Tests whether wc is a wide-character code representing a character of class "alpha" in the program's current locale. isenglish(wc) Tests whether wc is a wide-character code representing an English language character, excluding ASCII characters. isideogram(wc) Tests whether wc is a wide-character code representing an ideographic language character, excluding ASCII characters. isnumber(wc) Tests whether wc is a wide-character code representing digit [0-9], excluding ASCII characters. isphonogram(wc) Tests whether wc is a wide-character code representing a phonetic language character, excluding ASCII characters. isspecial(wc) Tests whether wc is a wide-character code representing a special language character, excluding ASCII characters. iswalnum(wc) Tests whether wc is a wide-character code representing a character of class "alpha" or "digit" in the program's current locale. iswascii(wc) Tests whether wc is a wide-character code representing an ASCII character. iswblank(wc) Tests whether wc is a wide-character code representing a character of class "blank" in the program's current locale. This function is not available to applications conforming to standards prior to SUSv3. See standards(5). iswlower(wc) Tests whether wc is a wide-character code representing a character of class "lower" in the program's current locale. iswcntrl(wc) Tests whether wc is a wide-character code representing a character of class "cntrl" in the program's current locale. iswdigit(wc) Tests whether wc is a wide-character code representing a character of class "digit" in the program's current locale. iswgraph(wc) Tests whether wc is a wide-character code representing a character of class "graph" in the program's current locale. iswprint(wc) Tests whether wc is a wide-character code representing a character of class "print" in the program's current locale. iswpunct(wc) Tests whether wc is a wide-character code representing a character of class "punct" in the program's current locale. iswspace(wc) Tests whether wc is a wide-character code representing a character of class "space" in the program's current locale. iswupper(wc) Tests whether wc is a wide-character code representing a character of class "upper" in the program's current locale. iswxdigit(wc) Tests whether wc is a wide-character code representing a character of class "xdigit" in the program's current locale. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ |ATTRIBUTE TYPE |ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |See below. | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ The iswalpha(), iswalnum(), iswblank(), iswcntrl(), iswdigit(), iswgraph(), iswlower(), iswprint(), iswpunct(), iswspace(), iswupper(), and iswxdigit() functions are Standard. SEE ALSO
localedef(1), setlocale(3C), stdio(3C), ascii(5), attributes(5), standards(5) SunOS 5.11 19 Apr 2004 iswalpha(3C)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy