Computing.Net > Forums > Programming > csv file using ksh

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

csv file using ksh

Reply to Message Icon

Name: charlyrosario
Date: June 24, 2007 at 13:21:03 Pacific
OS: linux
CPU/Ram: 1Gb/1Gb
Product: HPDL580
Comment:

I am working in ksh trying to get one line csv file from the output of File System information. The problem i facing is that i cannot get all information into one line csv file like:
/,50,/usr,70,/var,30
Example
#/usr/bin/ksh
df -k |grep -v mount > FS.log
FS=`cat FS.log |awk '{printf (%s,%d\n,$5,$6)}`
echo $FS >> FS.csv


Charlyrosario



Sponsored Link
Ads by Google

Response Number 1
Name: ghostdog
Date: June 25, 2007 at 01:11:46 Pacific
Reply:

df -k | awk 'BEGIN{OFS=","}{print $5,$6}' > FS.csv


0

Response Number 2
Name: charlyrosario
Date: June 25, 2007 at 07:13:55 Pacific
Reply:

Hi ghostdog,
The output of your command generates the same situation.
I am getting:
/,45
/usr,30
...etc

And i need: /,45,/usr,30,/var,50 in one line

Charlyrosario


0

Response Number 3
Name: nails
Date: June 25, 2007 at 09:08:35 Pacific
Reply:

A common way to place everything on 1 line is to use the xargs command:

df -k | nawk 'BEGIN{OFS=","}{print $5,$6}'|xargs


0

Response Number 4
Name: ghostdog
Date: June 25, 2007 at 09:16:34 Pacific
Reply:

then use printf, eg printf "%d,%s,",$5,$6


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: csv file using ksh

delete x number of lines from a CSV file www.computing.net/answers/programming/delete-x-number-of-lines-from-a-csv-file/19820.html

Extracting rows from multiple csv files using www.computing.net/answers/programming/extracting-rows-from-multiple-csv-files-using/20204.html

Read csv file using strtok C functn www.computing.net/answers/programming/read-csv-file-using-strtok-c-functn/7024.html