Sponsored Content
Top Forums Shell Programming and Scripting append existing file with zeroes bsed on position Post 302366050 by kshuser on Wednesday 28th of October 2009 04:22:40 PM
Old 10-28-2009
Quote:
Originally Posted by danmero
Code:
awk -F'[ |-]' '{$0=(NF==3)?$0 OFS f:((NF==2)?$0 OFS f OFS f:$0)}1' f="0000000" file

thanks danmero !!

I am getting the following error when i run your code
[CODE]
Code:
>awk -F'[ |-]' '{$0=(NF==3)?$0 OFS f:((NF==2)?$0 OFS f OFS f:$0)}1' f="0000000" wedtest3_appnd_zero.txt

awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

BTW in your code where is the input file parameter and output file parameter.

thnks

Last edited by kshuser; 10-28-2009 at 05:30 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shell script to append a time for the existing error log file

Hi Guys, the requirement is like this, i am having a error log file in this format, 4594.493: parallel nursery GC 2594592K->2544691K (2969600K), 30.848 ms 4605.958: parallel nursery GC 2634887K->2584986K (2969600K), 38.900 ms 4619.079: parallel nursery GC 2822555K->2774812K... (12 Replies)
Discussion started by: gsprasanna
12 Replies

2. Shell Programming and Scripting

Append line based on fixed position

Hi all; I'm having headache on append one line to another based on the fix position.Hope u guys can help. All i need to do is append the line that start with '3' to a line which start with '1' and the position for line 3 that i need to append is 22. The original file look like this: ... (2 Replies)
Discussion started by: ashikin_8119
2 Replies

3. Shell Programming and Scripting

append newline to existing variables

firstly, i check is the variable empty or not, if so vesselNameList=`echo $vesselName` if not vesselNameList="${vesselNameList}""\n"`echo "$vesselName"` and it produces this result BUNGA TERATAI 3 5055\ JADE TRADER 143W\ MOL SPLENDOR 0307A BUNGA TERATAI 3 5055\ JADE... (1 Reply)
Discussion started by: finalight
1 Replies

4. Shell Programming and Scripting

Add leading zeroes to numbers in a file

Hello, I am (trying) to write a script that will check to see how many users are logged on to my machine, and if that number is more than 60 I need to kill off all the oldest sessions that are over 60. So far I have been able to check how many users are on and now I am at the part where I have to... (3 Replies)
Discussion started by: raidzero
3 Replies

5. Shell Programming and Scripting

append each line on fixed position 31 to 33

I have a .DAT file like below. 26666666660001343 000001004OLF 029100020090820 27777777770000060 000001004ODL-CH001000020090820 28888888880000780 000001013OLF 006500020090820 ....... ........ and so on..... I want to append each line in a file in .KSH script with XXX with position... (5 Replies)
Discussion started by: kshuser
5 Replies

6. Shell Programming and Scripting

append the position 28:33

I have a file FILE1.DAT like below 21111111110001343 000001004OLF-AA029100020091112 21111111110000060 000001004ODL-CH001000020091112 24444444440001416 000001045OLF-AA011800020091112 23333333330001695 000001039OLF-AA030600020091112 23333333330000111 000001039ODL-SP002000020091112... (2 Replies)
Discussion started by: new2ksh
2 Replies

7. Shell Programming and Scripting

Append files to a existing tar file.

Hi all, I want to check whether tar file exists in the directory or not. If tar file exists in the directory then I want to append the files to it. I am using the below command to tar files if the file does not exist. tar zcvf <tar file name> <Files to append> However, if want to... (4 Replies)
Discussion started by: Nagaraja Akkiva
4 Replies

8. Shell Programming and Scripting

Append to existing line

I have a file which has lines that end with a plus (+) sign. I would like to get the next line appended to the one with the plus. For example bla bla bla bla bla + blip blip blip would become bla bla bla bla bla blip blip blip However not all lines end with a plus sign . I would... (2 Replies)
Discussion started by: bombcan
2 Replies

9. Shell Programming and Scripting

Perl - Append data to existing excel cell

Hello All, I have the following code in PERL to write data to excel sheet. Can someone please help me about how to append data to an exisitng cell? For ex in the below given case,Cell 1,1 has Active State PERL Now I want to add a new line like "prorgamming" without overwritting the... (3 Replies)
Discussion started by: prasperl
3 Replies

10. Shell Programming and Scripting

Matching column then append to existing File as new column

Good evening I have the below requirements, as I am not an experts in Linux/Unix and am looking for your ideas how I can do this. I have file called file1 and file2. I need to get the second column which is text1_random_alphabets and find that in file 2, if it's exists then print the 3rd... (4 Replies)
Discussion started by: mychbears
4 Replies
ost::SharedFile(3)					     Library Functions Manual						ost::SharedFile(3)

NAME
ost::SharedFile - This class defines a database I/O file service that can be shared by multiple processes. SYNOPSIS
#include <file.h> Inherits ost::RandomFile. Public Member Functions SharedFile (const char *path) Open or create a new database file. SharedFile (const SharedFile &file) Create a shared file as a duplicate of an existing shared file. virtual ~SharedFile () Close and finish a database file. Error restart (void) Restart an existing database; close and re-open. Error fetch (caddr_t address=NULL, ccxx_size_t length=0, off_t position=-1) Lock and Fetch a portion of the file into physical memory. Error update (caddr_t address=NULL, ccxx_size_t length=0, off_t position=-1) Update a portion of a file from physical memory. Error clear (ccxx_size_t length=0, off_t pos=-1) Clear a lock held from a previous fetch operation without updating. Error append (caddr_t address=NULL, ccxx_size_t length=0) Add new data to the end of the file. off_t getPosition (void) Fetch the current file position marker for this thread. bool operator++ (void) bool operator-- (void) Additional Inherited Members Detailed Description This class defines a database I/O file service that can be shared by multiple processes. Each thread should access a dup of the database object, and mutex locks can be used to preserve transaction integrety if multiple threads are used. SharedFile is used when a database may be shared between multiple processes. SharedFile automatically applies low level byte-range 'file locks', and provides an interface to fetch and release byte-range locked portions of a file. Author: David Sugar dyfet@ostel.com This class defines a database I/O file service that can be shared by multiple processes. Constructor &; Destructor Documentation ost::SharedFile::SharedFile (const char *path) Open or create a new database file. You should also use Initial. Parameters: path pathname of database to open. ost::SharedFile::SharedFile (const SharedFile &file) Create a shared file as a duplicate of an existing shared file. Parameters: file original file. virtual ost::SharedFile::~SharedFile () [virtual] Close and finish a database file. Member Function Documentation Error ost::SharedFile::append (caddr_taddress = NULL, ccxx_size_tlength = 0) Add new data to the end of the file. Locks file during append. @param address address to use, or NULL if same as last I/O. @param length length to use, or 0 if same as last I/O. Error ost::SharedFile::clear (ccxx_size_tlength = 0, off_tpos = -1) Clear a lock held from a previous fetch operation without updating. Returns: errSuccess on success. Parameters: length length to use, or 0 if same as last I/O. pos file position to use or -1 if same as last I/O. Error ost::SharedFile::fetch (caddr_taddress = NULL, ccxx_size_tlength = 0, off_tposition = -1) Lock and Fetch a portion of the file into physical memory. This can use state information to fetch the current record multiple times. Returns: errSuccess on success. Parameters: address address to use, or NULL if same as last I/O. length length to use, or 0 if same as last I/O. position file position to use -1 if same as last I/O. off_t ost::SharedFile::getPosition (void) Fetch the current file position marker for this thread. Returns: file position offset. bool ost::SharedFile::operator++ (void) bool ost::SharedFile::operator-- (void) Error ost::SharedFile::restart (void) [inline], [virtual] Restart an existing database; close and re-open. Returns: errSuccess if successful. Reimplemented from ost::RandomFile. Error ost::SharedFile::update (caddr_taddress = NULL, ccxx_size_tlength = 0, off_tposition = -1) Update a portion of a file from physical memory. This can use state information to commit the last read record. The current lock is also cleared. Returns: errSuccess on success. Parameters: address address to use, or NULL if same as last I/O. length length to use, or 0 if same as last I/O. position file position to use or -1 if same as last I/O. Author Generated automatically by Doxygen for GNU CommonC++ from the source code. GNU CommonC++ Sat Jun 23 2012 ost::SharedFile(3)
All times are GMT -4. The time now is 07:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy