Sponsored Content
Top Forums Shell Programming and Scripting Creating a csv file based on Existing file Post 302148460 by bakunin on Sunday 2nd of December 2007 05:25:34 AM
Old 12-02-2007
Thats quite straightforward. Find a script skeleton below:

Code:
#! /bin/ksh
typeset    fInput="/data/m/b.csc"      # input filename
typeset    fOutput="/data/o/tran.csv"  # output filename

if [ -r "$fInput" ] ; then     # perhaps there should be more input validation
     print -u2 "unable to read input file"
     exit 1
fi

sed 's/^\([^,]*,[^,]*,[^,]*,\)\([0-9]\{1,5\}\),/\1000\2/
     s/^\([^,]*,\)[^,]*,\([^,]*,[^,]*,[^,]*,\)[^,]*,\([^,]*\).*$/\1\2\3/' $fInput > $fOutput

exit $?

Hope this helps.

bakunin
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

i want to delete a file based on existing file in a directory

hi i am having four files in a directory.like 1)sampleRej 2)exampleRej 3)samplemain 4)examplemain my requirement is i have to search for the rejected files (sampleRej,exampleRej) in a directory.if these files in that directory then i have to delete the main files... (3 Replies)
Discussion started by: srivsn
3 Replies

2. Shell Programming and Scripting

Creating/ammending Name Column in existing .txt file

With the help of this forum, I have a script with the following output: chr7 27104483 27105154 chr7 27106872 27110789 chr7 27111956 27112830 chr7 27114388 27125180 chr7 27126966 27131260 chr7 27135440 27137796 which was created by the following script: awk '1 == NR || $NF >= 1000 {... (6 Replies)
Discussion started by: awknerd
6 Replies

3. Shell Programming and Scripting

Creating a new file based on existing file

Hello Guys , I need an another help regarding the below problem. I want to create a new file based on the existing file ,where two columns will be changed according to user input .(say column 4 and column 5) Please let me know how to proceed with Thanks (3 Replies)
Discussion started by: Pratik4891
3 Replies

4. Shell Programming and Scripting

Creating file from an existing file using CUT, is it the best option?

Dear All, I have a requirement in which i have to load a file placed in FTP location onto my database. The process i'll follow is as below: 1) Get the files using FTP. 2) Create the desired load files as i have to load only 19 fields out of the 104 available in the file. The fields i require... (7 Replies)
Discussion started by: abhishekakaomi
7 Replies

5. Shell Programming and Scripting

generate a file from existing file based on some rule

Hi guys, i have a file in below format.let me explain first what i am trying to do . i am making a file from this file , will rearrange these columns, then i will run several command(start/stop mentioned in this file) on unix environment. my requirements : 1. i have 27 servers , on each server... (4 Replies)
Discussion started by: deepakiniimt
4 Replies

6. Shell Programming and Scripting

Need help in creating a file in required format form another existing file

I have a text file with contents like this: a,b,c, d~e,f,g,h~i,j ,k,l,m~n,o,p,q~ I need to convert this file into this format unix shell script commands: a,b,c,d~ e,f,g,h~ i,j,k,l,m~ n,o,p,q~ as you may have noticed, I need to retain the ~ signs at the end. Any help is greatly... (3 Replies)
Discussion started by: harsha1238
3 Replies

7. UNIX for Advanced & Expert Users

Creating the script for updating or replacing the existing http.conf file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. I have been building a proxy server using the apache mod proxy currently my solution is working , but i need to automate the process , suppose if any changes need to be made on... (0 Replies)
Discussion started by: satej
0 Replies

8. 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
File::HomeDir::Unix(3)					User Contributed Perl Documentation				    File::HomeDir::Unix(3)

NAME
File::HomeDir::Unix - Find your home and other directories on legacy Unix SYNOPSIS
use File::HomeDir; # Find directories for the current user $home = File::HomeDir->my_home; # /home/mylogin $desktop = File::HomeDir->my_desktop; # All of these will... $docs = File::HomeDir->my_documents; # ...default to home... $music = File::HomeDir->my_music; # ...directory $pics = File::HomeDir->my_pictures; # $videos = File::HomeDir->my_videos; # $data = File::HomeDir->my_data; # DESCRIPTION
This module provides implementations for determining common user directories. In normal usage this module will always be used via File::HomeDir. SUPPORT
See the support section the main File::HomeDir module. AUTHORS
Adam Kennedy <adamk@cpan.org> Sean M. Burke <sburke@cpan.org> SEE ALSO
File::HomeDir, File::HomeDir::Win32 (legacy) COPYRIGHT
Copyright 2005 - 2011 Adam Kennedy. Some parts copyright 2000 Sean M. Burke. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2012-10-19 File::HomeDir::Unix(3)
All times are GMT -4. The time now is 06:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy