Sponsored Content
Top Forums Shell Programming and Scripting Shell script to populate an array from a csv file Post 302597236 by Corona688 on Thursday 9th of February 2012 05:16:06 PM
Old 02-09-2012
Code:
#!/bin/bash

N=0
ARR=()

IFS=","

while read STR
do
        set -- "$STR"

        while [ "$#" -gt 0 ]
        do
                ARR[$N]="$1"
                ((N++))
                shift
        done
done < input.csv

This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using the getline to populate an array from a file

Hello, I am trying to use the awk getline command to populate an array from a flat file. Has anyone done this before? So we have file1: a b c d I want to create an array like index that contains these four elements (8 Replies)
Discussion started by: penfold
8 Replies

2. Shell Programming and Scripting

Modifying a csv file from Shell Script

Hi all, I have some script that creates a temp csv file. What I need to do is do some search and replace and modify the file from my shell script. I know the commands to open the file and then apply the reg ex but wasnt sure how I could do this from a script and modify the file? Any help... (2 Replies)
Discussion started by: not4google
2 Replies

3. UNIX for Advanced & Expert Users

format csv file using shell script

i have a report.csv file from oracle datavase In that file data is like this with report heading and date SALES DAILY REPORT DATE: 06-26-2007 REPORT NAME: SALES DATA AA.BB.CCCC.DDDD,BBBBB,06-26-2007,0,BEGIN,END ZZ.VV.DDDD.XXXXXXX,MMMMMM,06-25-2007,18,BEGIN,END... (3 Replies)
Discussion started by: raosurya
3 Replies

4. Shell Programming and Scripting

how to create csv file using shell script

I have a file in multiple directory which has some records in the following format File: a/latest.txt , b/latest.txt, c/latest.txt -> Name=Jhon Age=27 Gender=M Street=LA Road Occupation=Service I want to generate a csv file from the above file as follows File: output.csv -> ... (9 Replies)
Discussion started by: rjk2504
9 Replies

5. Shell Programming and Scripting

populate specified value in csv

Hi, I've requirement of populating two blank column ( 4rth and 6th ) in a csv file with specified value for all the rows having value within the first colmn. I know it can be done with sed, as given in the below command, but i am not sure how pull blank value or specify target column etc or... (11 Replies)
Discussion started by: john_prince
11 Replies

6. Shell Programming and Scripting

Using eval to populate an array in the background

Hi. I am trying to populate an array using eval in the background within a function. So this function will create a list of 3 character directories from SVN and store in an array. I want to call this function when the script starts in the background unknown to the user. The problem is that... (2 Replies)
Discussion started by: jmiaebrown
2 Replies

7. UNIX for Dummies Questions & Answers

Help to parse csv file with shell script

Hello ! I am very aware that this is not the first time this question is asked here, because I have already read a lot of previous answers, but none of them worked, so... As said in the title, I want to read a csv file with a bash script. Here is a sample of the file: ... (4 Replies)
Discussion started by: Grhyll
4 Replies

8. Shell Programming and Scripting

Reading a csv file using shell script

Hello All, I have a csv file that looks like below ProdId_A,3.3.3,some text,some/text,sometext_1.2.3 ProdId_B,3.3.3,some text,some/text,sometext_1.2.3 ProdId_C,3.3.3,some text,some/text,sometext_1.2.3 ProdId_A,6.6.6,some text,some/text,sometext_9.9.9 I will get ProdId from... (5 Replies)
Discussion started by: anand.shah
5 Replies

9. Shell Programming and Scripting

CSV File Creation Within Shell Script

Hi All, I am trying to create a CSV file within a shell script test.ksh and the code snippet is something like below: #!/usr/bin/ksh # Set required variables. . $HOME/.prof # Output file path Group1=/tmp/G1.csv Group2=/tmp/G2.csv Group3=/tmp/G3.csv $ORACLE_HOME/bin/sqlplus -s... (2 Replies)
Discussion started by: swasid
2 Replies

10. Shell Programming and Scripting

Help with Shell Scrip in Masking particular columns in .csv file or .txt file using shell script

Hello Unix Shell Script Experts, I have a script that would mask the columns in .csv file or .txt file. First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder. Two parameters are passed ... (5 Replies)
Discussion started by: Mahesh G
5 Replies
RSRCE(1)							 Debian GNU/Linux							  RSRCE(1)

NAME
rsrce - editor for raw MacOS resource forks SYNOPSIS
rsrce [-e] [-f script] [-o output-file] [input-file] DESCRIPTION
Rsrce is a command driven Macintosh resource fork editor for Unix-like operating systems. It works with raw resource forks stored in Unix files, such as the .rsrc files produced by the macutil package. Rsrce doesn't allow you to edit the resource data directly. It only knows to import/export them from/to files, performing conversion for the few resource types it knows. OPTIONS
-e When this option is given, the failure of an editor command will cause rsrce to quit immediately with a non-zero exit status. This is similar to the -e option to /bin/sh. -f script Instructs rsrce to read its commands from the given script, instead of using the standard input. -o output-file Specifies a default output file for the writecommand. Useful when calling rsrce scripts which save their changes with a write com- mand without a filename. If an input-file is specified, it is loaded before rsrce starts reading commands, and is used as the default output file if the -o option has not been given. USAGE
Rsrce reads commands from the standard input. Unquoted whitespace is ignored, except for the purpose of separating arguments. Empty lines are ignored, and a # at a position where an argument would have started indicates a comment which extends to the end of the line. Text within single quotes is used as-is. An unquoted backslash can be used the way it works in C strings, or to force literal interpretation of the following character. Resources are referred to by specifing their type and id, separated by a colon. I mean, something like "STR#:128". If the given type has less than 4 letters, spaces are added to complete it. The following commands are available: read [file] read the resources from file write [file] write the resources to file create resource create a new, empty resource with the given type and id delete resource remove the specified resource rename resource new-name change the name associated with resource to new-name chattr resource attr-spec change the attributes of resource according to attr-spec ls list each resource's type, id, attributes, data lenght, and name hexdump resource show an hexdump of resource's data import|export resource file [ext] import/export resource's data from/to file. The conversion which is performed depends on the extension of the given filename. This extenstion may be overriden by providing the extargument. edit resource[ext] invoke an external editor to change resource's data help list available commands exit terminate rsrce (without saving, use write before exit if you wish to save your changes) CONVERSION OF RESOURCE DATA
When rsrce imports or exports resource data, a conversion can be performed depending on the resource type and the extension of the provided filename. The following extensions are known to rsrce: bin causes no conversion, the raw resource data is used regardless of the resource type; txt causes the resource data to be converted to plain text. This is possible for STR, STR#andCMDLresources. BUGS
Rsrce has only been originally created to change the configuration of the miBoot Linux bootloader for OldWorld PowerMac computers. Since I do not use MacOS, I haven't tested any other usage of this program. You should therefore be very careful when using it, as it could very well produce unusable output. Another consequence of this is wildly missing functionnality. I'm not going to work on it, since I couldn't test anything in a real situa- tion. Patches and/or usage reports would be very welcome. AUTHOR
Jeremie Koenig <sprite@sprite.fr.eu.org> SEE ALSO
hfsutils(1), macutil(1) Debian Project 2004-03-26 RSRCE(1)
All times are GMT -4. The time now is 05:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy