Sponsored Content
Top Forums Shell Programming and Scripting Replace a word based upon the file content Post 303025025 by RudiC on Tuesday 23rd of October 2018 06:12:17 AM
Old 10-23-2018
Unfortunately, none of your attempts targets close to what you specify. Did you analyse the very precise error msgs, showing the exact location of the syntax fault? Are you sure about your fields' distribution (you specify two fields but reference $3)?

There are umpteen ways to skin a cat. How far would this get you?
Code:
awk -v SQ="'" '
$2 == "timestamp"       {$0 = "dataformat(" SQ "YYYY-MM-DD HH:NN:SS.sss)" SQ}
$2 == "date"            {$0 = "dataformat(" SQ "YYYY-MM-DD)" SQ}
1
' file
a smallint
dataformat('YYYY-MM-DD HH:NN:SS.sss)'
dataformat('YYYY-MM-DD)'
d varchar


EDIT: So close to this (which I saw only now...).

Last edited by RudiC; 10-23-2018 at 07:55 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find filename based on file content

:confused: There is a flat file on my system which contains email addreses of people in my company. This file is utilized when sending notifications for various things. However nobody knows where this file is located or what it is named. The only thing we know is the email address of a user who... (4 Replies)
Discussion started by: kollerj
4 Replies

2. Shell Programming and Scripting

Dynamic naming based on file content

I was just thinking if there is a way where i can dynamically rename files based on the actual file content. I have a load of pdf's which have been named wrongly. (We normally put date first, then brief description, then title) So can a script be written wherin, it pulls out the date and title... (2 Replies)
Discussion started by: deaddevil
2 Replies

3. Shell Programming and Scripting

Change file content based on data

I have a Transaction File coming into the system. In this file, in all records the relevant data is as follows- Position 1:10 -> Transaction Code Position 252:255 -> 4 digit business code Now based on these 2 fields I have to alter value in Transaction code (Position 1:10)... (6 Replies)
Discussion started by: varunrbs
6 Replies

4. Shell Programming and Scripting

Replace a word after a particular word in a file

Hi, I want to replace a word in a file which occurs after a particular word. For example : $cat file.txt CASE WHEN AND c1 = 'I' AND c2= '2' THEN 1 WHEN AND c1= 'I' AND c2= '0' THEN 2 So in this example i want to replace... (4 Replies)
Discussion started by: ashwin3086
4 Replies

5. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (2 Replies)
Discussion started by: perl_beginner
2 Replies

6. Shell Programming and Scripting

Help with replace column one content based on reference file

Input file 1 testing 10 20 1 A testing 20 40 1 3 testing 23 232 2 1 testing 10 243 2 . . Reference file 1 final 3 used . . Output file (1 Reply)
Discussion started by: perl_beginner
1 Replies

7. Shell Programming and Scripting

Split the file based on the content

Arun kumar something somehting Enterting in to the line . . . . Some text text Finshing the sentence Some other text . . . . Again something somehting Enterting in to the line . . . . . . Again text text Finshing the sentence (6 Replies)
Discussion started by: arukuku
6 Replies

8. Shell Programming and Scripting

Sed: replace content from file with the content from file

Hi, I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C. Thanks a lot!! Here is a sample of my question. e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies

9. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

10. Shell Programming and Scripting

How to create file and file content based existing information?

Hi Gurus, I am SQL developer and new unix user. I need to create some file and file content based on information in two files. I have one file contains basic information below file1 and another exception file file2. the rule is if "zone' and "cd" in file1 exists in file2, then file name is... (13 Replies)
Discussion started by: Torhong
13 Replies
ESPCTAG(1)							   User Manuals 							ESPCTAG(1)

NAME
espctag - Edit tags of SPC files (ID666) SYNOPSIS
espctag [OPTION]... IFILE... DESCRIPTION
By default, espctag prints ID666 tags extracted from SPC files (SNES audio files) on the standard output. When called with the --set switch, flags accept an argument and the corresponding fields are modified. Files are processed in the order specified. OPTIONS
-s, --set Set tags -g, --get Print tags. This is the default behaviour -f, --file Print file names -n, --field Don't print field names -t, --type Print tags format -a, --all Select all fields. Can not be used with --set -S[SONG_TITLE], --song[=SONG_TITLE] Print/Set song title -G[GAME_TITLE], --game[=GAME_TITLE] Print/Set game title -N[DUMPER_NAME], --dumper[=DUMPER_NAME] Print/Set dumper name -C[COMMENTS], --comments[=COMMENTS] Print/Set comments -D[MM/DD/YYYY], --date[=MM/DD/YYYY] Print/Set dump date -L[LENGTH], --length[=LENGTH] Print/Set length of song (without fade length) -F[LENGTH], --fade[=LENGTH] Print/Set fadeout length -A[ARTIST], --artist[=ARTIST] Print/Set artist name -M[CHANNELS], --channels[=CHANNELS] Print/Set default channels states (0 = channel is enable / 1 = channel is disable) -E[EMULATOR], --emulator[=EMULATOR] Print/Set emulator used to make the dump BUGS
Please, submit bug reports on the sourceforge project page, at the following address : https://sourceforge.net/tracker/?group_id=563796&atid=2286949 AUTHOR
Jerome SONRIER <jsid@emor3j.fr.eu.org> Linux SEPTEMBER 2011 ESPCTAG(1)
All times are GMT -4. The time now is 02:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy