File Space Problem


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File Space Problem
# 1  
Old 09-03-2008
File Space Problem

I have a file which have 2 columns.

chris doc,male
test,female

So in order to store the content of the first column i am doing this :-

Code:
for line in $( cat $test.csv ); do
     FIRST_COLUMN_VAR=$( echo $line | cut -d"," -f1 )
     SECOND_COLUMN_VAR=$( echo $line | cut -d"," -f2 )
     echo $FIRST_COLUMN_VAR

I get the output :-

chirs
doc
test

Which is wrong. So then i tried to put quotes so then my script recognizes as "chris doc" one word rather than 2 word .

Code:
for line in "$( cat $test.csv ); do
     FIRST_COLUMN_VAR=$( echo $line | cut -d"," -f1 )
     SECOND_COLUMN_VAR=$( echo $line | cut -d"," -f2 )
     echo $FIRST_COLUMN_VAR

I get the output :-
chris doc

It does not read the second row at all. Any hints or suggestions?
# 2  
Old 09-03-2008
where read line
do
first_column=`echo "$line"|awk -F"," '{print $1}'`
second_column=`echo "$line"|awk -F"," '{print $2}'`
echo "$first_column"
done < test.csv
# 3  
Old 09-03-2008
Thanks Vidhya. So i need to use AWK in order to get the column which contains space. Got it. I tried IFS=',' and couple of other stuff but everytime i was running into this problem.
# 4  
Old 09-03-2008
Another one :

Code:
sed 's/\(.*\),\(.*\)/\1/' filename

# 5  
Old 09-03-2008
Quote:
Originally Posted by chris1234
Thanks Vidhya. So i need to use AWK in order to get the column which contains space. Got it. I tried IFS=',' and couple of other stuff but everytime i was running into this problem.
there is no restriction that you need to use awk.. as dennis said you can do it by simple sed..
or simply awk -F"," '{print $1}' filename
# 6  
Old 09-03-2008
Issue resolved

Last edited by chris1234; 09-03-2008 at 05:39 PM..
# 7  
Old 09-03-2008
Quote:
Originally Posted by chris1234
Ah. When i put my logic in that while loop for some reason it works for first row only not for second row.
whats your logic can you post it??
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Problem space used on AIX 5.3

Hello everyone, Sorry for my English but i'm French. I have a problem on an AIX 5.3 server on the occupation of a file system. When i run a df -m, this is what i get : Filesystem MB blocks Free %Used Iused %Iused Mounted on /dev/fslv09 3936.00 340.94 92% 7255 ... (8 Replies)
Discussion started by: Veis
8 Replies

2. UNIX for Dummies Questions & Answers

Changing only the first space to a tab in a space delimited text file

Hi, I have a space delimited text file but I only want to change the first space to a tab and keep the rest of the spaces intact. How do I go about doing that? Thanks! (3 Replies)
Discussion started by: evelibertine
3 Replies

3. UNIX for Advanced & Expert Users

Swap space problem

Hy! Recently i had a problem with one of mine Tru64 machines. It started to kill processes because of low amount of swap space. It said that it went below 10 %. But when i ran swapon -s it said: In-use space: 12 % So, the system couldn't accept any new ssh connections plus it killed most of... (1 Reply)
Discussion started by: veccinho
1 Replies

4. UNIX for Dummies Questions & Answers

Space problem in files

Hi, I have a file containing a list of entries. Want to do ls on them. for a in `cat <list.txt>`; do ls $a; done; Now some entries contain spaces. How do i incorporate space in $a. Quoting $a in "" doesn't help. Thanks (6 Replies)
Discussion started by: vibhor_agarwali
6 Replies

5. UNIX for Dummies Questions & Answers

Unix -- Space problem -- File number limitation?

Dear all Recently I cant touch file in one mount point (which is not full, 78% full only), it says can't write to device, obviously it means it's full, I deleted some files and I can write some files only. I wonder is there any file number limitation in a mount point and how can I check or how... (2 Replies)
Discussion started by: shanemcmahon
2 Replies

6. Shell Programming and Scripting

Everywhere space problem

Solved.... (1 Reply)
Discussion started by: redbeard_06
1 Replies

7. UNIX for Dummies Questions & Answers

Linux space problem

I am very new to Linux and trying to install Oracle 9.2 on Red Hat Linux 7.2. My problem: /tmp needs to be larger in order to install Oracle. It is 64MB now. How can I resize this? I'm totally confused !! Thanks. (7 Replies)
Discussion started by: canova
7 Replies

8. Filesystems, Disks and Memory

problem with swap space

I have sun solaris 8 for intell with 128m physiccal ram and swap of 148. Oracle requires to have 512M swap space. Is there a way I can change the swap space on intell machine without repartioning the box:? what if i create a link to /swap from another place???? pls advise Jigar (1 Reply)
Discussion started by: jigarlakhani
1 Replies

9. UNIX for Advanced & Expert Users

Problem with space

I am in the initial stage of learning UNIX. I got PC with Intel SUN SOLARIS S/W. I am planning to install Oracle on the same machine. I have created /export with more than 3gb space, when I have installed the OS. As a Oracle user when I am trying to create a directory I am able to get only 512... (4 Replies)
Discussion started by: suraj
4 Replies

10. UNIX for Dummies Questions & Answers

root file system space problem

Dear all My actual root file system size is 1 gb, only OS installed . other than OS i did n't installed in this slice. but It shows 100% full. When try to create space , I couldn't find any files other than OS. What may be the reason? Help.... any one pls. (2 Replies)
Discussion started by: sbaloo
2 Replies
Login or Register to Ask a Question