Sponsored Content
Top Forums Shell Programming and Scripting Help with file editing while keeping file format intact Post 302482136 by Mruda on Monday 20th of December 2010 05:16:04 PM
Old 12-20-2010
Code:
echo "$LINE" | sed "s/,$SERVICE_CODE,/,$SERVICE_CODE_NUM,/g" >>temp5.txt
 
echo "$LINE" | sed "s/$SERVICE_CODE/$SERVICE_CODE_NUM/g" >>temp5.txt

Both is giving same output as before, removing all space. It does not give any error.

-----------------------------
Code:
sed "s/$SERVICE_CODE/$SERVICE_CODE_NUM/g" inputFile >temp5.txt

-----------------------------
works fine. but i am not sure if i can use it.
Because I need to do some validations on each line before updating it.

Last edited by Franklin52; 12-21-2010 at 07:48 AM.. Reason: Please use code tags, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keeping the format ...

Hi all, Am trying to execute a loop but having some troubles... Files that will be query'd use the Julian date (eg: cpu032, cpu365) in their naming convention. I'm a little lost how to maintain the three character format of the numeric portion of the file name while cycling backwards(or... (13 Replies)
Discussion started by: Cameron
13 Replies

2. UNIX for Dummies Questions & Answers

creating separate directories according to file extension and keeping file in different directory as

unix program to which a directory name will be passed as parameter. This directory will contain files with various extensions. This script will create directories with the names of the extention of the files and then put the files in the corresponding folder. All files which do not have any... (2 Replies)
Discussion started by: Deekay.p
2 Replies

3. HP-UX

Editing a UNIX file in Hexadecimal format

Hi, I am a newbie to the UNIX world. I am asked to edit the file in hexadecimal format and save it. Later I should be able to print the file in char mode. please anyone tell me how to do that mostly using VI editor. (1 Reply)
Discussion started by: vkudire
1 Replies

4. UNIX for Dummies Questions & Answers

sort by keeping the headings intact?

Hi all, I have a file with 3 columns separated by space. Each column has a heading. I want to sort according to the values in the 2nd column (ascending order). Ex. Name rank direction goory 0.05 --+ laby 0.0006 --- namy 0.31 -+- ....etc. Output should be Name rank direction laby... (3 Replies)
Discussion started by: Unilearn
3 Replies

5. Shell Programming and Scripting

Keeping the number intact

Currently I have the following to separate the numeric values. However the decimal point get separated. ls -lrt *smp*.cmd | awk '{print $NF}' | sed 's/^.*\///' | sed 's/\(*\)/ & /g' As an example on the files n02-z30-dsr65-terr0.50-dc0.05-4x3smp.cmd... (8 Replies)
Discussion started by: kristinu
8 Replies

6. Shell Programming and Scripting

editing line in text file adding number to value in file

I have a text file that has data like: Data "12345#22" Fred ID 12345 Age 45 Wilma Dino Data "123#22" Tarzan ID 123 Age 33 Jane I need to figure out a way of adding 1,000,000 to the specific lines (always same format) in the file, so it becomes: Data "1012345#22" Fred ID... (16 Replies)
Discussion started by: say170
16 Replies

7. Shell Programming and Scripting

Remove last few characters in a file but keeping Header and trailer intact

Hi All, I am trying write a simple command using AWK and SED to this but without any success. Here is what I am using: head -1 test1.txt>test2.txt|sed '1d;$d' test1.txt|awk '{print substr($0,0,(length($0)-2))}' >>test2.txt|tail -1 test1.txt>>test2.txt Input: Header 1234567 abcdefgh... (2 Replies)
Discussion started by: nvuradi
2 Replies

8. Shell Programming and Scripting

Grab data between 2 keywords any do an array operation and write the file intact

Hi Unix Gurus, I need to grep for a block that is between a start and end keyword and then in between I need to find and replace a keyword. for eg: I need to search between Test = 000; and Test = 000; and find K9 and replace with M9 INPUT FILE Define { Replace = K9; Test =... (6 Replies)
Discussion started by: naveen@
6 Replies

9. Shell Programming and Scripting

Remove duplicates by keeping the order intact

Hello friends, I have a file with duplicate lines. I could eliminate duplicate lines by running sort <file> |uniq >uniq_file and it works fine BUT it changes the order of the entries as it we did "sort". I need to remove duplicates and also need to keep the order/sequence of entries. I... (1 Reply)
Discussion started by: magnus29
1 Replies

10. Shell Programming and Scripting

Keeping record of file 2 based on a reference file 1 in awk

I have 2 input files (tab separated): file1: make_A 1990 foo bar make_B 2010 this that make_C 2004 these those file2: make_X 1970 1995 ref_1:43 ref_2:65 make_A 1970 1995 ref_1:4 ref_2:21 ref_3:18 make_A 1980 2002 ref_1:7 ref_2:7 ref_3:0 ... (2 Replies)
Discussion started by: beca123456
2 Replies
FANN_READ_TRAIN_FROM_FILE(3)						 1					      FANN_READ_TRAIN_FROM_FILE(3)

fann_read_train_from_file - Reads a file that stores training data

SYNOPSIS
resource fann_read_train_from_file (string $filename) DESCRIPTION
Reads a file that stores training data. PARAMETERS
o $filename - The input file in the following format: num_train_data num_input num_output inputdata seperated by space outputdata seperated by space inputdata seperated by space outputdata seperated by space RETURN VALUES
Returns a train data resource on success, or FALSE on error. EXAMPLES
Example #1 fann_read_train_from_file example <?php $train_data = fann_read_train_from_file("xor.data"); if ($train_data) { // Do something with $train_data for XOR function } ?> Contents of xor.data 4 2 1 -1 -1 -1 -1 1 1 1 -1 1 1 1 -1 SEE ALSO
fann_train_on_data(3), fann_destroy_train(3), fann_save_train(3). PHP Documentation Group FANN_READ_TRAIN_FROM_FILE(3)
All times are GMT -4. The time now is 12:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy