read and cut

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read and cut
# 1  
Old 10-04-2007
read and cut

hi i am KSH shell script newbieSmilie 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 .....Smilie

Last edited by kkc; 10-04-2007 at 11:13 PM..
# 2  
Old 10-04-2007
elaborate more

firstly, i dont quite understand ur question..

csv file is separated by can read it like any other normal file

did u meaan cut the 2'nd line of the file and print- then

sed -n '/2/p' filename.csv

did u mean cut the 2'nd column of the file and print

while read line

filed2= `cut -d, -f2`
echo $filed2
done < filename.csv

Devaraj Takhellambam
# 3  
Old 10-05-2007
Smiliesorry for my poor englishSmilie

according to your script

while read line

filed2= `cut -d, -f2`
echo $filed2
done < filename.csv

/users/sally/myprogram1;My Program 1;
/users/sally/myprogram2;My Program 2;
this is the line which iis nside the filename.csv
so how to separate the /users/sally/myprogram1; as file1 and
My Program 1; as file2 by using cut command so the result will be echo $file1 and echo $file2
anyway thanks alot..Smilie
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. UNIX for Dummies Questions & Answers

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 (1 Reply)
Discussion started by: vino_hymi
1 Replies

6. 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

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