Using the entire line with space in between


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using the entire line with space in between
# 1  
Old 07-03-2014
Using the entire line with space in between

Hi Folks,

I have a report data like the one seen below.

Code:
FRUITS@NEW_ORANGE(1500 04/29)
FRUITS@NEW_ORANGE(1500 05/04)
FRUITS@NEW_ORANGE(1500 05/05)
FRUITS@NEW_ORANGE(1500 05/07)
FRUITS@NEW_ORANGE(1500 05/12)

I need to use each of this lines separately in another for loop like the one shown below.

Code:
for i in `cat fruit.txt`
do
echo $1
done

The output of this script comes like

Code:
FRUITS@NEW_ORANGE(1500
04/29)
FRUITS@NEW_ORANGE(1500
05/04)
FRUITS@NEW_ORANGE(1500
05/05)
FRUITS@NEW_ORANGE(1500
05/07)
FRUITS@NEW_ORANGE(1500
05/12)

But i need the output like

Code:
FRUITS@NEW_ORANGE(1500 04/29)
FRUITS@NEW_ORANGE(1500 05/04)
FRUITS@NEW_ORANGE(1500 05/05)
FRUITS@NEW_ORANGE(1500 05/07)
FRUITS@NEW_ORANGE(1500 05/12)

can someone help?

Thanks
# 2  
Old 07-03-2014
Code:
while read i
do
echo "$i"
done < fruit.txt

ALWAYS use this form of loop to read data from file.
# 3  
Old 07-03-2014
That worked Smilie Smilie Smilie

Thanks much !!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to extract entire para instead of just line?

Hello, I have a file with multiple paragraphs/sections each starting with word "Handle" and if I grep for a pattern, I should get contents of entire section/para (not just line). Please advise, thanks! #script.sh file.txt "System Information" Handle 0x0001 DMI type 1, 27 bytes. ... (9 Replies)
Discussion started by: reddyr
9 Replies

2. Shell Programming and Scripting

Help with sed to replace entire line

Hi, I need to replace an entire mailx line as follows using sed: sed -e 's/<line1>/<newline>/g' <filename> But I am getting comman garbled error since the new line has many special characters. I enclosed allspecial chars in \ but still no use. Can any one help me? Please use code... (2 Replies)
Discussion started by: vinodhin4
2 Replies

3. Shell Programming and Scripting

Delete entire line starting with space

Folks, How do i delete an entire line that starts with blank space? Ex: I have a file like below. abc def (10/12) ghi _________ jkl _________ mno pqr stu (11/12) vwx I need the ouput like abc def (10/12) ghi pqr stu (11/12) vwx Thanks for your elp in advance !!!! (2 Replies)
Discussion started by: jayadanabalan
2 Replies

4. UNIX for Dummies Questions & Answers

Show the entire line using ps

Using the vanilla ps -ef I noticed that the CMD (or command) line gets cut off after 90 characters UID PID PPID C STIME TTY TIME CMD root 6020 3822 0 Jun 19 ? 0:01 ./webservd-wdog -r /export/opt/sows/61sp4 -d /export/opt/sows/61sp4/https-logse Googling... (4 Replies)
Discussion started by: SixSigma1978
4 Replies

5. Shell Programming and Scripting

grep to find entire line ....

As per my understanding below mentioned line of code finding a word 'boy' in $ACULOG... num_errors=`grep -i -e fail -e illegal -e exception -e "<E" -e boy $ACULOG | wc -l` if I'm not corerct, please correct me. How I can find entire line like "This is a boy" with something similar as above... (1 Reply)
Discussion started by: heyitsmeok
1 Replies

6. SCO

SCO507 not recognizing entire disk space on install

Hello, I'm trying to install 507 on an HP G5 ML350 server, and I've hit a snag. The installation goes fine until I try to customize the Unix partition on the harddrive--SCO will only see 50 GB of disk space (49852 to be exact). I've installed an HP P400 Smart Array Controller and set up 2... (3 Replies)
Discussion started by: asab
3 Replies

7. Shell Programming and Scripting

Replace entire line

I want to replace one line from my configuration file with the new settings. The file Name: /etc/httpd/conf/httpd.conf The following line should be replaced with the line mentioned below. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "\"%h\"... (3 Replies)
Discussion started by: shantanuo
3 Replies

8. Shell Programming and Scripting

print entire line after if lookup

I hope this is a basic question. I have a file with a bunch of strings in each line (and the string number is variable). What I want to do is a simple if command and then print the entire line. something like awk '{if ($3=="yes") print $1,$2,$3,...$X }' infile > outfile Can someone... (1 Reply)
Discussion started by: dcfargo
1 Replies

9. UNIX for Dummies Questions & Answers

grep entire statement not just line

(extract from SQL binlog file...) # at 4960 #080801 14:35:31 server id 4 end_log_pos 195 Query thread_id=63121426 exec_time=0 error_code=0 use d_jds; SET TIMESTAMP=1217581531; UPDATE bid_details set bidding = 3170.37 ,deduction=if((3170.37 < 37.43),0,deduction) where... (3 Replies)
Discussion started by: shantanuo
3 Replies

10. Shell Programming and Scripting

Capture entire line in ps command

I need to determine what processes are running at certain times of the day. I have a script that issues the /usr/ucb/ps aux command and captures it to a file. I want to see the cpu usage and memory usage. This command lops off the end of the of the display line so I can't see the entire... (2 Replies)
Discussion started by: MizzGail
2 Replies
Login or Register to Ask a Question