Sponsored Content
Top Forums Shell Programming and Scripting Replace delimited value with specific conditions Post 303007287 by Don Cragun on Wednesday 15th of November 2017 01:59:15 AM
Old 11-15-2017
The code Scrutinizer suggested should work on a correctly functioning awk, but GNU awk sometimes handles regular expressions slightly differently than the way they are specified in the standards. But, the error you are getting is coming from the Korn shell; not from awk and mismatched double-quotes inside a single-quoted string in a shell script should have absolutely no effect on the number of parentheses that the shell sees as shell operators (i.e., none).

Although, in theory, it shouldn't make any difference, please try the following slight modifications of Scrutinizer's suggestion:
Code:
awk '{for(i=1; i<=NF; i++) {gsub(/^["]|["]$/,"^",$i); gsub(/["]/,"§",$i)}}1'  FS=\~ OFS=\~  file.txt

and:
Code:
awk '{for(i=1; i<=NF; i++) {gsub(/^\"|\"$/,"^",$i); gsub(/\"/,"§",$i)}}1'  FS=\~ OFS=\~  file.txt

and let us know if either of these produce different results.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Updating specific fields with awk using conditions

Can someone help me again, I think with awk? I have a file with 4 columns (pipe-delimited): I just want to convert the last field so that e1 is now 'message 1', e2 is 'message 2', e0 is 'message 3', etc. I don't want to change any other columns because the e0-e10 code may appear as part of a... (4 Replies)
Discussion started by: giannicello
4 Replies

2. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

3. Shell Programming and Scripting

Find and replace a string a specific value in specific location in AIX

Hi, I have following samp.txt file in unix. samp.txt 01Roy2D3M000000 02Rad2D3M222222 . . . . 10Mik0A2M343443 Desired Output 01Roy2A3M000000 02Rad2A3M222222 . . (5 Replies)
Discussion started by: techmoris
5 Replies

4. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

5. UNIX for Dummies Questions & Answers

move files that match specific conditions

Hi all, I'm new to this forum and bash scripting. I have the following problem, I need to copy some files (from one dir. to another) whose first 5 numbers (subjects' ID) match the directory names. Here a shortened version of what I'm trying to do: names=(32983_f 35416_f 43579_f) # these are... (6 Replies)
Discussion started by: ada1983
6 Replies

6. Shell Programming and Scripting

How to copy or cut specific rows from appended file with some conditions

Hi I have one file which is containing about 5000 rows and 20 columns I will just explain about my requirement here briefly with sample file, I have attached also, please help....me.. 1 28.25 36.42 5 28.26 36.42 10 28.23 36.43 15 28.22 36.43 20 28.2 36.42 25... (6 Replies)
Discussion started by: nex_asp
6 Replies

7. Shell Programming and Scripting

Replace specific column range in a non-delimited file with a string!

Hi All, I will need an help with respect to replacing a range of columns on a non-delimited file using a particular string pattern. Say file input is MYNUMBERD000000-BAN CHUE INSNTS ** N+ MYAREDSDD000000+BAN CHUE INSNTS ** N+ MYDERFFFSD00000-GIR PENT - ACH ** ... (5 Replies)
Discussion started by: navojit dutta
5 Replies

8. UNIX for Dummies Questions & Answers

Find and replace single character w/awk given conditions

I have a file that looks like this: 14985 DPN verb PPa to spend. 12886 DPNDJN bay tree. 15686 DQ verb to observe 15656 KC ... (7 Replies)
Discussion started by: jvoot
7 Replies

9. Shell Programming and Scripting

awk to assign points to variables based on conditions and update specific field

I have been reading old posts and trying to come up with a solution for the below: Use a tab-delimited input file to assign point to variables that are used to update a specific field, Rank. I really couldn't find too much in the way of assigning points to variable, but made an attempt at an awk... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. Shell Programming and Scripting

Search and replace value based on certain conditions in a fixed width file

Hi Forum. I tried searching for a solution using the internet search but I haven't been able to find any solution for what I'm trying to accomplish. I have a fixed width column file where I need to search for any occurrences of "D0" in col pos.#1-2, 10-11, 20-21 and replaced it with "XD". ... (2 Replies)
Discussion started by: pchang
2 Replies
BLAZE-LIST(1)						    BlazeBlogger Documentation						     BLAZE-LIST(1)

NAME
blaze-list - lists blog posts or pages in the BlazeBlogger repository SYNOPSIS
blaze-list [-cpqrsCPSV] [-b directory] [-I id] [-a author] [-t title] [-T tag] [-d day] [-m month] [-y year] [-n number] blaze-list -h|-v DESCRIPTION
blaze-list lists existing blog posts or pages in the BlazeBlogger repository. Additionally, it can also display basic repository statistics. OPTIONS
-b directory, --blogdir directory Allows you to specify a directory in which the BlazeBlogger repository is placed. The default option is a current working directory. -I id, --id id Allows you to display a single blog post or a page with the specified id. -a author, --author author Allows you to list blog posts or pages by the selected author. -t title, --title title Allows you to list blog posts or pages with matching title. -T tag, --tag tag Allows you to list blog posts or pages with matching tag. -d day, --day day Allows you to list blog posts or pages from the specified day of a month. The value has to be in the "DD" form. -m month, --month month Allows you to list blog posts or pages from the specified month. The value has to be in the "MM" form. -y year, --year year Allows you to list blog posts or pages from the specified year. The value has to be in the "YYYY" form. -n number, --number number Allows you to specify a number of blog posts or pages to be listed. -p, --page Tells blaze-list to list pages. -P, --post Tells blaze-list to list blog posts. This is the default option. -S, --stats Tells blaze-list to display statistics. -s, --short Tells blaze-list to display each blog post or page information on a single line. -r, --reverse Tells blaze-list to display blog posts or pages in reverse order. -c, --color Enables colored output. When supplied, this option overrides the relevant configuration option. -C, --no-color Disables colored output. When supplied, this option overrides the relevant configuration option. -q, --quiet Disables displaying of unnecessary messages. -V, --verbose Enables displaying of all messages. This is the default option. -h, --help Displays usage information and exits. -v, --version Displays version information and exits. EXAMPLE USAGE
List all blog post: ~]$ blaze-list ID: 11 | 2010-07-05 | Jaromir Hradilek Title: Join #blazeblogger on IRC Tags: announcement ID: 10 | 2009-12-16 | Jaromir Hradilek Title: Debian and Fedora Packages Tags: announcement etc. List all blog post in reverse order: ~]$ blaze-list -r ID: 1 | 2009-02-10 | Jaromir Hradilek Title: BlazeBlogger 0.7.0 Tags: release ID: 2 | 2009-02-11 | Jaromir Hradilek Title: BlazeBlogger 0.7.1 Tags: release etc. List all pages: ~]$ blaze-list -p ID: 5 | 2009-02-10 | Jaromir Hradilek Title: Downloads ID: 4 | 2009-02-10 | Jaromir Hradilek Title: Themes etc. List each blog post on a single line: ~]$ blaze-list -s ID: 11 | 2010-07-05 | Join #blazeblogger on IRC ID: 10 | 2009-12-16 | Debian and Fedora Packages etc. Display a short version of blog statistics: ~]$ blaze-list -Ss There is a total number of 11 blog posts and 5 pages in the repository. SEE ALSO
blaze-config(1), blaze-add(1) BUGS
To report a bug or to send a patch, please, add a new issue to the bug tracker at <http://code.google.com/p/blazeblogger/issues/>, or visit the discussion group at <http://groups.google.com/group/blazeblogger/>. COPYRIGHT
Copyright (C) 2009-2011 Jaromir Hradilek This program is free software; see the source for copying conditions. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Version 1.2.0 2012-03-05 BLAZE-LIST(1)
All times are GMT -4. The time now is 04:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy