Help needed to split a line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed to split a line
# 1  
Old 09-27-2011
Help needed to split a line

Hi,
How can i split a line of string into two lines.

I would like to format the below string:
Code:
Filesystem 1M-blocks Used Available Use% Mounted on /abc/def/xyz 34567 2345 12345 90% /test

to

Code:
Filesystem 1M-blocks Used Available Use% Mounted on
/abc/def/xyz 34567 2345 12345 90% /test

Can anyone plz help me with this...

Thanks in Advance!!!

Last edited by pludi; 09-27-2011 at 11:22 AM..
# 2  
Old 09-27-2011
Where are you getting this string from (complete command please), and how do you output it (again, complete command please)?
# 3  
Old 09-27-2011
Hi,
Thanks for replying. This is the script which emails the disk usage report.

Code:
#!/bin/sh

#Writing to a file
exec > report.txt

#Check the amount of disk space
checksize=`df -h /test` 

echo $checksize

#email the file
cat report.txt | mail abc@xyz.com

And this is how it displays on the email
Code:
Filesystem 1M-blocks Used Available Use% Mounted on /abc/def/xyz 34567 2345 12345 90% /test

But i want it to be displayed like this
Code:
Filesystem 1M-blocks Used Available Use% Mounted on
/abc/def/xyz 34567 2345 12345 90% /test

Please help!!
Thank You!!!
# 4  
Old 09-27-2011
Use
Code:
echo "$checksize"

instead. For an explanation please take a look at the many many threads concerned with quoting.
# 5  
Old 09-27-2011
Awesome!!
It works...Thanks a lot!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a line

I have a very long line in a file separated by "|" delimiter like below. Due to the length of the line, I find it very difficult to read to find a match line. file = temp.txt word 1| word 2 | word 3|.... I would like to read the file temp.txt and print out all words line by line like... (1 Reply)
Discussion started by: boldnbeautiful
1 Replies

2. UNIX for Dummies Questions & Answers

Split Every Line In Txt Into Separate Txt File, Named Same As The Line

Hi All Is there a way to export every line into new txt file where by the title of each txt output are same as the line ? I have this txt files containing names: Kandra Vanhooser Rhona Menefee Reynaldo Hutt Houston Rafferty Charmaine Lord Albertine Poucher Juana Maes Mitch Lobel... (2 Replies)
Discussion started by: Nexeu
2 Replies

3. Shell Programming and Scripting

Read a File line by line and split into array word by word

Hi All, Hope you guys had a wonderful weekend I have a scenario where in which I have to read a file line by line and check for few words before redirecting to a file I have searched the forum but,either those answers dint work (perhaps because of my wrong under standing of how IFS... (6 Replies)
Discussion started by: Kingcobra
6 Replies

4. Shell Programming and Scripting

Help needed - Split large file into smaller files based on pattern match

Help needed urgently please. I have a large file - a few hundred thousand lines. Sample CP START ACCOUNT 1234556 name 1 CP END ACCOUNT CP START ACCOUNT 2224444 name 1 CP END ACCOUNT CP START ACCOUNT 333344444 name 1 CP END ACCOUNT I need to split this file each time "CP START... (7 Replies)
Discussion started by: frustrated1
7 Replies

5. UNIX for Dummies Questions & Answers

Using Awk to split a line

Hi, I have a file that contains multiple lines e.g. /Plane/Wing/Engine/Rotorblades I cannot use print $4 as the directories will be different lengths. All i would like to do is print the very last column in each line in the file i.e. in this case, Rotorblades. The code i... (4 Replies)
Discussion started by: crunchie
4 Replies

6. Shell Programming and Scripting

Split a line

I guess this has a simple solution but can't figure out now. having: x="H:a:b:c" to get H: echo $x|awk -F: {'print $1'} how can I put REST of line in another one? i.e. echo $rest a:b:c thanks ---------- Post updated at 08:58 PM ---------- Previous update was at... (5 Replies)
Discussion started by: garagonp
5 Replies

7. Shell Programming and Scripting

split single line into two line or three lines

Dear All, I want to split single line into two line or three lines wherever “|” separated values comes using Input line test,DEMTEMPUT20100404010012,,,,,,,,|0070086|0070087, output shoule be test,DEMTEMPUT20100404010012,,,,,,,,0070086, test,DEMTEMPUT20100404010012,,,,,,,,0070087, (14 Replies)
Discussion started by: arvindng
14 Replies

8. Shell Programming and Scripting

Split a line on positions before reading complete line

Hi, I want to split before reading the complete line as the line is very big and its throwing out of memory. can you suggest. when i say #cat $inputFile | while read eachLine and use the eachLine to split its throwing out of memory as the line size is more than 10000000 characters. Can you... (1 Reply)
Discussion started by: vijaykrc
1 Replies

9. Shell Programming and Scripting

Help Needed : Split one big file to multiple files

Hi friends, I have data in flat file as following, first filed is the customer number. We have almost 50-100 customers in the system 100 ABC A123 100 BVC D234 100 BNC N324 200 CBC A122 200 AVC D294 200 HNC N324 300 GBC A173 300 FVC D234 300 DNC N344 I want to split the file and... (5 Replies)
Discussion started by: monicasgupta
5 Replies

10. UNIX for Advanced & Expert Users

sed help split line

hi i have a file containing lines like word1,word2,word3,word4,.. word4,word5,word3,word6,... now i need to make it to look like word1 word2 word3 word4 . . . in other words ','(comma) is replaced with new line. (5 Replies)
Discussion started by: Raom
5 Replies
Login or Register to Ask a Question