![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | 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. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
Read file line spaces
I have a script which read a file it does
while read -r line, then i echo line out echo "$line" Problem is the echo does not echo space and tabs at the end of each line. How do i get the end of line space as well |
|
|||
|
If you simply want to echo each line out with its tabs and spaces on the end of each line then you can use nawk: - Code:
nawk 1 file This will loop through the file echoing each line onto stdout without modifying them |
|
|||
|
Code:
# cat file test line1 test line2 # cat file | od -c 0000000 t e s t l i n e 1 \t \n t e s t 0000020 l i n e 2 \t \n 0000030 # while IFS= read -r line;do echo $line | od -c ;done < file 0000000 t e s t l i n e 1 \n 0000013 0000000 t e s t l i n e 2 \n 0000013 # while IFS= read -r line;do echo "$line" | od -c ;done < file 0000000 t e s t l i n e 1 \t \n 0000014 0000000 t e s t l i n e 2 \t \n 0000014 |
|
|||
|
Code:
nawk 1 file | do your processing |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| shell script to read a line in gps receiver log file and append that line to new file | gudivada213 | Shell Programming and Scripting | 3 | 06-24-2009 07:16 AM |
| script to read a line with spaces bet " " and write to a file | perlamohan | Shell Programming and Scripting | 3 | 11-12-2008 04:27 AM |
| Read variables contain spaces from text file | ahmed.zaher | Shell Programming and Scripting | 1 | 10-20-2008 07:44 PM |
| ksh - read file with leading spaces | momi | Shell Programming and Scripting | 2 | 03-17-2008 03:02 PM |
| How to read a line when it starts with spaces | PrakashChinna | Shell Programming and Scripting | 3 | 07-03-2006 11:49 AM |