Share this on:

39 comment

  1. Thanks, I used this code and edited it. It’s the closest I’ve been to the output I need but for some reason using this to export each line as an individual variable isn’t working.

    Here is the script, my guess is that it’s a syntax issue of some sort. Thanks in advance for anyone who offers help!

    1. Can you tell me what are you trying to create here? If possible please use our forum for further discussion.

  2. Hi,
    I have 2 CSV files. let say emp_data_Jan.csv (will contain the data of employees till Jan) and emp_data_feb.csv (will contain the data of employees till Feb). I need a Shell script which can read both these files and compare the data between emp_data_Jan.csv and emp_data_feb.csv. After comparision i need the output data in new CSV file. Output data will be records which are present in emp_data_Feb.csv and not in emp_data_Jan.csv. Can any one help me out in this.

    Thanks in Advance


  3. Want to know how to read word by word for each line , from the file . what could be the seperator value for IFS

  4. Hi All,
    Here is another way-

  5. I was having a real mental block on the best way to read files in shell scripts and I found this site and example script. It was a real help. I did have the following thoughts though:

    I don’t think that it is really necessary to mess with IFS nor with saving and restoring FD 0. I have found that the following adaptation seems to do the job. (With one alteration: not defaulting the input file to stdin)

    YMMV. Hope this helps someone else.

  6. Thanks a lot. It works fine. when i read a text from a file and create a new file using that text two small letters disappearing from the text and that leads to an invalid file path . two letters are “e”and “n”. while reading from the file it fails to read these two letters . could you please tell me possible reason for this . is it taking those letters as some delimiter or something ?

    Pre requesties

    1)template.txt in the same path contains a text “ordprg”and a blank line

    2) in the same path contains two lines
    Following program will eliminate “e” and “n”

    # Please Respond to this Thanks in Advance

  7. @michelek,

    This can be easily fixed by adding following code before and after while loop:

    while / for / untile loop is using $IFS to determine what the field separators are. I’ve modified this to use end of line. Here is final modified code:

    The script has been updated to fix this issue. Just download updated version.


  8. Hey this worked perfectly. I used it to automatically patch my sun system. I used smpatch analyze > patch.txt then used your script to read in the outputed patch numbers.

    Have a question? Post it on our forum!