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:
(Copied and pasted from Excel for Mac, but there should be ";")
And here is the simplified code I am trying to make work:
And... it won't work. Nothing comes out.
If I just do "more $file", then I have a beautiful output:
(I could not reproduce it here, but the "^M" are written in white on a black background.)
I have tried using cat or echo instead of more, without success, I have even tried sed and awk with some of the many solutions given on the internet, but they did not work neither, and I would prefer not to use awk if possible, since I do not really understand it yet.
Another strange thing is that if I do:
Then I have as output only the last line of the file and not the others...
I am kind of stuck here, without any additionnal idea.
I don't even absolutely want to use csv files, it is just that this format is convenient if many people have to change the source file, so if you have in mind a format easier to read with bash, let me know.
I hope I've given all the needed information and that one of you will have an idea...
Thanks for the try, but it does not work :/ The code you provided does not give anything in output
What is more, when I do a simple cat on my csv file, only the last line is displayed... Maybe there are some libs I don't have to support csv reading with bash ?
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)
Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database.
I need to write the korn shell program on Red Hat Enterprise Linux server.
Oracle database is 10g. (15 Replies)
Raw Results:
results|192.168.2|192.168.2.1|general/udp|10287|Security Note|For your information, here is the traceroute from 192.168.2.24 to 192.168.2.1 : \n192.168.2.24\n192.168.2.1\n\n
results|192.168.2|192.168.2.1|ssh (22/tcp)|22964|Security Note|An SSH server is running on this port.\n... (2 Replies)
Hi,
I need to parse input file from 2nd line.
Input file contents are,
ABC123;20100913115432;2000000;NO;
04;AAA;09;DDD;601020304;AAAA;1;OPTA1;OPTA2;;;
04;BBB;09;BBB;601020304;BBBB;0;OPTB1;OPTB2;OPTB3;OPTB4;OPTB5;
04;CCC;09;DDD;601020304;CCCC;1;;;;;
For each line,
1] I need to check... (17 Replies)
Hi Everybody,
I have an XML file containing some data and i want to extract it, but the specific issue in my file is that the data is repeated some times like the following example :
<section1>
<subsection1>
X=...
Y=...
Z=...
<\subsection1>
<subsection2>
X=...
Y=...
Z=...... (2 Replies)
hi all,
i have a html file something similar to this.
<tr class="evenrow">
<td class="data">added</td><td class="data">xyz@abc.com</td>
<td class="data">filename.sql</td><td class="modifications-data">08/25/2009 07:58:40</td><td class="data">Added TK prof script</td>
</tr>
<tr... (1 Reply)
Hi,
It's been a few years since college when I did stuff like this all the time. Can someone help me figure out how to best tackle this problem? I need to parse a file full of entries that look like this:
<eq action="A" sectyType="0" symbol="PGR" exch="CA" curr="VEF" sess="NORM"... (7 Replies)
I am faced with a :confused: tricky problem to parse a data file ( May not be a tricky problem to the scripting guru's ).
Here is what I am faced with. I have a file with multiple rows of data and the rows are not of fixed length. "|" is used as a delimiters for individual columns and each row... (3 Replies)
I am writing a unix script that will parse a CSV and edit the values. My CSV looks like this
0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0
10,11,7,0,4,12,2,3,7,0,11,3,12,4,0,5,5,4,5,0,8,6,12,0,9,3,3,0,2,7,8... (16 Replies)
Hi! I'm just new here and don't know much about shell scripting. I just want to ask for help in creating a shell script that will parse a string or value of the status in the xml file. Please sample xml file below. Can you please help me create a simple script to get the value of status? Also it... (46 Replies)