I have to generate the file dynamically from the source file based on the below control file.
The control file contain the position of column which i required from the source file, Example 1 column ,3 column ,5 column ,blank column(-1 indicates blank column) and so on..
I have written a shell to read one by one position from control file to generate multiple files and finally used paste command to generate new files incase of -1 values i created touch files. Based on sequence of file order its's pasted by ls-v option.
So my existing shell looks like below,
I hope there is a way to minimize the I/O of files, I am looking for something below,
or better solution will be great.
The number of column in source files will be in hundred's
Expected results:
input-file is sample.csv
output.csv
output.csv is based on controlfile.txt
Please suggest me to get some idea , I hope sed can help me to achieve !!
Last edited by Scrutinizer; 09-18-2014 at 04:40 AM..
Reason: alligned; (mod) change bold tags to code tags
That will be difficult like that because cut will not keep the order of columns. Also you need to somehow put the the columns in file 2 into shell variables first. That wil become a bit cumbersome with a lot of external programs..
An alternative would be to use awk, that for example:
Note, however, that if you using a UNIX System (rather than a Linux System),awk probably won't work if any lines in your input file are longer than 2048 bytes (actually whatever number is returned by getcont LINE_MAX). With hundreds of input fields, this may be a problem depending on what OS you're using.
Hi,
I am using the nested for loops to generate the sequence ,
taking start and end sequence number input from test.txt
(sample content mentioned below).
Also , can I print the rest of columns as well with sequence number into the same file.
for i in `cat test.txt|cut -d"," -f7`
do ... (8 Replies)
A big hello to everyone tagged to this site of knowledge . This is the first post of mine and I am looking forward to an enjoyable stint in this forum where I get to know a lot of new ideas and share whatever knowledge (its not much though :) ) I have acquired throughout my career so far with... (4 Replies)
Hi All,
Can anyone give me Shell script sample script to generate Param file by Reading Values from SQL Plus query and it should assign those values to variables like..
$$SChema_Name='ORCL'
Thanks in Advance... Srav... (4 Replies)
Hi Team,
I'm using HP UX. I want to pass a variable dynamically as input while executing the script and that value need to be replaced with a string in the script. I tired SED, in the command line its working but while I keep the same command in the script its not working. Can someone help me... (4 Replies)
Hi,
I am new to this unix scripting, I got a requirement like..
Files with *.XML extension will be generating in a /home/sample/ folder for every 15 mins. I need to monitor those files in that particular folder for every hour.
If no file has been generated in that particular folder for an... (7 Replies)
Hi,
I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format.
Example:
File.txt
AP|{SSHA}VEEg42CNCghUnGhCVg==
APVG3|{SSHA}XK|"password"
AP3|{SSHA}XK|"This is test"
....
etc
---------
test.sh has... (1 Reply)
Hi,
I'm not an expert in awk but i need a simple script to do this:
I'd like to AutoCrop PDF files.
I found 2 simple script that combined together could help me to automatize :)
The first utiliti is "pdfinfo" that it gives the MediaBox and TrimBox values from the pdf.
The pdfinfo output... (8 Replies)
I need to run a shell script with dynamic command in it like
# Begin script...
mysql xx "select * from tab" | sed 's/\t/|/g' > GENERATED_20100304.txt
the dynamic part is 20100304 which should be today's date, and it needs to run every day and create a new file with... (2 Replies)
Hello
I am trying to create a dynamic ksh script and I have an issue.
I have a script a.ksh and it has got the following lines (for example)
#!/bin/ksh
# trace mode +x : without trace -x : with trace
set +xv
echo hi, i am going to create a dynamic script now
cat >> dynamic.ks <<EOF... (2 Replies)
Hi Gurus,
I have a requirement of writting the shell script where it should ask me two values
FND_TOP=/d02/app/oracle/xxx/fnd/11.5.0
CDCRM_TOP=/d02/app/oracle/xxx/cdcrm/11.5.0
and then keep these values stored as variables for the execution of rest of the script.
Because, I have to... (2 Replies)