Cut and read


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cut and read
# 1  
Old 09-17-2010
Cut and read

Hi,


I have a file which contains comma separated values ex: abc, bdc
I need to read this file and provide each value(one by one) as a input to other function.

Can some one helpme...

-Vinodh' Kumar
# 2  
Old 09-17-2010
Something to get you started. We can read the file and convert each comma to a newline.
Assming this is a Bourne-type shell.

Code:
cat filename.csv | tr ',' '\n' | while read parameter
do
        echo "${parameter}"
done

./scriptname
abc
bdc

This User Gave Thanks to methyl For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies

2. Shell Programming and Scripting

How to make the cut command read a column after logical statements are meet?

Hi, I want to write a code that will cut everything that is under a couple of columns in a text file but so far I am not even close to achieve something like that. Basically, I want to cut all the information from the columns and transfer the column information to a spread sheet. I have... (1 Reply)
Discussion started by: pericopericone
1 Replies

3. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

4. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

5. Shell Programming and Scripting

Need to read data from a file (cut/awk)

Hi list, i have an orcale spool file with SQL> select COMPMAP as SVC, ITEM, UNIT, sum(JAN), sum(FEB) SVC ITE U SUM(JAN) SUM(FEB) ------ --- - ---------- ---------- 401500 IOC Q 14 14 406200 LC Q 1 1 410124 IOC Q 5 4 410124 LC... (1 Reply)
Discussion started by: rejirajraghav
1 Replies

6. Shell Programming and Scripting

read and cut

hi i am KSH shell script newbie:o i would like to ask how to create a shell script to read the CSV file then follow by cut the file line number 2 and echo it this 2nd line... i need some coding refference .....:confused: (2 Replies)
Discussion started by: kkc
2 Replies

7. Shell Programming and Scripting

How reverse cut or read rows of lines

Hi, My records are like this BSC403_JAIN03|3153_TropicalFarm_LIMJM1-3_97| BSC403_JAIN03|3410_PantaiAceh_PCEHM1_4_97| BSC406_BMIN02|1433_JomHebohTV3_COW7M1_11_97| I want to extract the value before _97| This command BSC_ID=`echo $DATA | cut -f5 -d"_"` gives me _97|, 4, 11 and by... (16 Replies)
Discussion started by: doer
16 Replies

8. Shell Programming and Scripting

read string, check string length and cut

Hello All, Plz help me with: I have a csv file with data separated by ',' and optionally enclosed by "". I want to check each of these values to see if they exceed the specified string length, and if they do I want to cut just that value to the max length allowed and keep the csv format as it... (9 Replies)
Discussion started by: ozzy80
9 Replies
Login or Register to Ask a Question