Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Problem with replacing chars in file Post 302707091 by pamu on Friday 28th of September 2012 03:23:37 AM
Old 09-28-2012
try with awk..

Code:
awk -F, '{if($2 ~ /AAA/) {$2="AAAdummy"}else if($2 == "" && NF > 2) { $2 = "dummy"}}1' OFS=, file

with sed....

Code:
sed 's/AAA[a-zA-Z0-9\t]\+,/AAAdummy,/; s/,,/,dummy,/' file

This User Gave Thanks to pamu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

to append few chars at the end of a file

hi i want to open a file at runtime append few chars at the end of each line all these i want to have done automatically how to do it (2 Replies)
Discussion started by: trichyselva
2 Replies

2. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies

3. UNIX for Dummies Questions & Answers

Using SED to get n chars after given value from file

Hello, my name is Marc, I'm a linux starter :) and I hope you specialists can help me solving this issue. I have a file containing a lot of data. Somewhere in this file, there's a string called "Faultdump", directly followed by 64 chars of HEX data. I need to get the HEX part. I accomplished... (12 Replies)
Discussion started by: Kally
12 Replies

4. UNIX for Advanced & Expert Users

Problem in FTP of file with chinese chars

Hi, I have a file in my PC with Chinese (PRC) characters. When I transfer that file into my AIX5.3 server through FTP, I get junk characters instead of Chinese chars. Last week I copied the content from my notepad and pasted in vi editor. The Chinese characters were correct, but when I try now,... (4 Replies)
Discussion started by: carthyc
4 Replies

5. Shell Programming and Scripting

find 4 chars on 2nd line, 44 chars over

I know this should be simple, but I've been manning sed awk grep and find and am stupidly stumped :( I'm trying to use sed (or awk, find, etc) to find 4 characters on the second line of a file.txt 44-47 characters in. I can find lots of sed things for lines, but not characters. (4 Replies)
Discussion started by: unclecameron
4 Replies

6. UNIX for Dummies Questions & Answers

Splitting a file based on first 8 chars

I have an input file of this format <Date><other data> For example, 20081213aaaaaaaaa 20081213bbbbbbbbb 20081220ccccccccc 20081220ddddddddd 20081220eeeeeeeee 20081227ffffffffffffff The first 8 chars are date in YYYYMMDD formT. I need to split this file into n files where n is the... (9 Replies)
Discussion started by: paruthiveeran
9 Replies

7. Shell Programming and Scripting

Removing unknow chars from file names.

I'm trying to move a large folder to an external drive but some files have these weird chars that the external drive won't accept. Does anyone know any command of any bash script that will look through a given folder and remove any weird chars? (4 Replies)
Discussion started by: Joktaa
4 Replies

8. UNIX for Dummies Questions & Answers

Replacing multiple special chars with single char

Hi I've a string . And i need to replace set of characters with a single character Means .. or . or ... and so on should be replaced with single % character Irrespective of number of dots in between the characters , those should be replaced with single % All the above strings should be... (3 Replies)
Discussion started by: smile689
3 Replies

9. Shell Programming and Scripting

Problem wth spec chars in script

Hello I would like to make a script which will get the line from file list (ex. passkey) and put it into further processing. The main problem is that lines, in text file contains all specials characters, and whitespaces too, as these that was used as a extremmaly-safe passwords. I have written... (4 Replies)
Discussion started by: elxa1
4 Replies

10. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies
textutil::tabify(3tcl)				    Text and string utilities, macro processing 			    textutil::tabify(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
textutil::tabify - Procedures to (un)tabify strings SYNOPSIS
package require Tcl 8.2 package require textutil::tabify ?0.7? ::textutil::tabify::tabify string ?num? ::textutil::tabify::tabify2 string ?num? ::textutil::tabify::untabify string ?num? ::textutil::tabify::untabify2 string ?num? _________________________________________________________________ DESCRIPTION
The package textutil::tabify provides commands that convert between tabulation and ordinary whitespace in strings. The complete set of procedures is described below. ::textutil::tabify::tabify string ?num? Tabify the string by replacing any substring of num space chars by a tabulation and return the result as a new string. num defaults to 8. ::textutil::tabify::tabify2 string ?num? Similar to ::textutil::tabify this command tabifies the string and returns the result as a new string. A different algorithm is used however. Instead of replacing any substring of num spaces this command works more like an editor. num defaults to 8. Each line of the text in string is treated as if there are tabstops every num columns. Only sequences of space characters containing more than one space character and found immediately before a tabstop are replaced with tabs. ::textutil::tabify::untabify string ?num? Untabify the string by replacing any tabulation char by a substring of num space chars and return the result as a new string. num defaults to 8. ::textutil::tabify::untabify2 string ?num? Untabify the string by replacing any tabulation char by a substring of at most num space chars and return the result as a new string. Unlike textutil::tabify::untabify each tab is not replaced by a fixed number of space characters. The command overlays each line in the string with tabstops every num columns instead and replaces tabs with just enough space characters to reach the next tabstop. This is the complement of the actions taken by ::textutil::tabify::tabify2. num defaults to 8. There is one asymmetry though: A tab can be replaced with a single space, but not the other way around. BUGS, IDEAS, FEEDBACK This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category textutil of the Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883]. Please also report any ideas for enhancements you may have for either package and/or documentation. SEE ALSO
regexp(3tcl), split(3tcl), string(3tcl) KEYWORDS
formatting, string, tabstops CATEGORY
Text processing textutil 0.7 textutil::tabify(3tcl)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy