![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove Trailing spaces after a delimiter | kiran_418 | UNIX for Dummies Questions & Answers | 1 | 04-29-2008 02:19 PM |
| Remove trailing G | Heathe_Kyle | Shell Programming and Scripting | 3 | 04-14-2008 10:56 AM |
| how to keep newline characters in command execution result? | pankai | Shell Programming and Scripting | 2 | 01-02-2008 05:41 PM |
| How to remove trailing spaces | mahek_bedi | UNIX for Dummies Questions & Answers | 2 | 08-10-2007 07:21 AM |
| Formatting a text file based on newline and delimiter characters | ntekupal | Shell Programming and Scripting | 5 | 05-11-2007 03:33 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
remove trailing newline characters
Hello ,
I have the folowing scenario : I have a text file as follows : (say name.txt) ABC DEF XYZ And I have one more xml file as follows : (say somexml.xml) <Name>ABC</Name> <Age>12</Age> <Class>D</Class> <Name>XYZ</Name> <Age>12</Age> <Class>D</Class> <Name>DEF</Name> <Age>12</Age> <Class>D</Class> I use each name from text , grep accordingly and extract three tags name,age,class from xml .. The extraction works fine and so does grep ...but i want to move that in a loop ... i.e. as follows : for each name in text file do something ....(grep in xml) i use the following command : cat name.txt | while read someLine set ${someLine} name=$someLine grep "$name" somexml.xml but the problem here occurs during readline coz it reads a newline alongwith the name due to which it cannot grep further in xml ..... So basically i want to remove the trailing newline character..... (I would kindly acknowledge even better and innovative ways of reading the file) Hope my problem is clear.... ![]() Thanks and Regards, SD |
|
|||||
|
Quote:
That command will permit us to determine if your problem comes from your data file. An example: Code:
$ od -c datas.txt 0000000 E s c a p e 033 a n d C R 0000020 \r i n s i d e \n 0000031 $ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|