The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
number of occurences of a string siddu_chittari Shell Programming and Scripting 12 12-05-2006 01:09 AM
$A is a number / any other string? How to determine ? csaha Shell Programming and Scripting 2 02-21-2006 04:03 AM
How to format number/string in ksh GNMIKE Shell Programming and Scripting 2 07-03-2005 03:44 PM
string to number George_king Shell Programming and Scripting 2 09-10-2003 04:48 PM
shell to number and to string xiamin Shell Programming and Scripting 1 11-06-2001 08:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-24-2008
hrwath hrwath is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
awk/sed - getting string instead of number

Hi!

I am writing a script handling downloading list of files and I have to check whether file is present locally and if not finished than continue downloading. To do so I have to compare sizes of remote file and local file.

To check remote file size I have to parse something like this:

Code:
Moon:~ jaja$ curl --cookie /tmp/rpd-cookie.txt -I -L -s http://domain.com/path/to/some/file.zip
HTTP/1.1 200 OK
P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa CONa TELa OUR STP UNI NAV STA PRE"
Date: Mon, 24 Mar 2008 07:49:21 GMT
Accept-Ranges: bytes
Content-Disposition: Attachment; filename=S02E02_20Simpson_20and_20Delilah.mp4
Content-Type: application/octet-stream
Content-length: 80566953
Connection: Keep-Alive
So, in a script I have a line:

Code:
REMOTESIZE=`curl --cookie /tmp/rpd-cookie.txt -I -L -s $1 | grep Content-length | awk '{print $2}'`
But the problem is that I'm getting a string with \r at the end. I tried various combinations, also with tr and sed but no results. Second value, parsed from ls is a valid integer but I can't handle the first one...

Anyone could give me some tip? It's bash-script.

Thanks
hrwath
  #2 (permalink)  
Old 03-24-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,913
Pipe to sed 's/.$//'
  #3 (permalink)  
Old 03-24-2008
hrwath hrwath is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 2
Great!

It works perfect. Thanks a lot.

hrwath
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0