parsing txt file, saving graphics files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parsing txt file, saving graphics files
# 1  
Old 02-07-2011
parsing txt file, saving graphics files

hi everyone,
i am a newbie in shell programming. and i want to simply go through a text file that contains 3 "columns", split by ';'

customerID ; link-to-contract ; save-as-filename

so an example would simply look like this

Quote:
232433:https-link-to-my-site/mypic.tff;232433.tiff
133333:https-link-to-my-site/mypic2.tff;133333.tiff
now i want to loop through every line, and save the file from the link as the name given at the end....how is best way and shortest way to do this?

thanks in advance.
# 2  
Old 02-07-2011
If the example has a typo, ie. 1st and 2nd field are separated by a semicolon instead of a colon, as described in your text, you could do something like this:
Code:
while read LINE; do
   A=`echo $LINE| cut -d";" -f2`
   echo ${A##*/}
done < infile

Result would be:
Code:
mypic.tff
mypic2.tff

# 3  
Old 02-07-2011
thanks a lot
but it does not work well with real links like

dp1.mylink.com:8083/doaFile/permalink?l8nj2BnEo34Pa

(the file behind the link is actually a tiff file)
# 4  
Old 02-07-2011
With bash:
Code:
while read LINE; do A=`echo $LINE| cut -d";" -f2`; echo ${A##*[?/]}; done < infile
mypic.tff
mypic2.tff
l8nj2BnEo34Pa


Last edited by zaxxon; 02-07-2011 at 12:57 PM.. Reason: marking the changes
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Saving files with file name as output

Hi, i need help with a file creation of an output program. I've got a program that with #find creates an output for each files in a directory. If i give this command : -o spec$(date -u +%Y%m%dt%H%M) it creates just one file, overwriting all the others since it is the creation date .... (2 Replies)
Discussion started by: Board27
2 Replies

2. Shell Programming and Scripting

Parsing a txt file according to two different tags

I need to parse a txt file like below. starts from the first occurence of SASN2010Aber.CallEventRecord.egsnPDPRecord { till the last occurence of } in other saying name of the part(header) is SASN2010Aber.CallEventRecord.egsnPDPRecord and the content of the header is in two... (3 Replies)
Discussion started by: snr_silencer
3 Replies

3. Shell Programming and Scripting

Compare two txt files,mismatches will be in new txt files

Hi, Below are the sample data for txt files. txt file 1 Partnumber|catgroup_id 10001082|46016 10001093|4680 10001093|386003 10001093|463004 10003251|683 10003251|63005 10003252|463005 10003252|4683 10003260|463005 10003260|4683 10003264|4683 10003264|463005 13420000|67... (5 Replies)
Discussion started by: Ankita Talukdar
5 Replies

4. Windows & DOS: Issues & Discussions

Parsing a UNIX txt to separate files

I have a requirement to parse a dataflex .txt file and break it into separate files within the Windows server env. Is there any special characters I should pay particular attention on the unix side? Any ideas? Thanks in advance (2 Replies)
Discussion started by: kicklinr
2 Replies

5. OS X (Apple)

[Solved] links2 --enable-graphics from source, configure error: no graphics driver found.

Howdy I am trying to install links2 with graphics support on snow leopard 10.6.8 (xcode installed). I have had the program running last year, also installed from source - but then I had installed some image libraries with mac ports and fink - cannot reproduce that setup. Plus I would like to not... (6 Replies)
Discussion started by: butterbaerchen
6 Replies

6. Shell Programming and Scripting

Parsing txt, xml files and preparing csv file

Hi, I need to parse text, xml files to get the statistic numbers and prepare summary csv file. What is the best way to parse these file and prepare csv file. Any idea you have , please? Regards, (2 Replies)
Discussion started by: LinuxLearner
2 Replies

7. UNIX for Dummies Questions & Answers

Assistance with combining, sorting and saving multi files into one new file

Good morning. I have a piece of code that is currently taking multiple files and using the CAT.exe command to combine into one file that is then sorted in reverse order based on the 3rd field of the file, then displayed on screen. I am trying to change this so that the files are being combined into... (4 Replies)
Discussion started by: jaacmmason
4 Replies

8. Shell Programming and Scripting

help parsing txt with awk

Hi all I would need some help to introduce 'break' lines into the following data by using awk: original data: RECORD 1000 aaa xxxxxx RECORD 1001 aaa xxxxxx RECORD 1002 bbb xxxxxx RECORD 1003 bbb xxxxxx RECORD 1004 bbb xxxxxx RECORD 1005 ccc xxxxxx RECORD 1006 ccc xxxxxx RECORD 1007... (5 Replies)
Discussion started by: yomaya
5 Replies

9. UNIX for Dummies Questions & Answers

Crontab keeps saving empty files of the job file.

Hey, MAILTO=cron@domain.ca */20 * * * * /usr/bin/wget http://list.domain.ca/admin/consume.php >/dev/nullthats what the crontab is setup todo, so basically every 20minutes it runs consume.php In my root directory, i'm getting files like this: consume.php consume.php1 consume.php2 i woke... (3 Replies)
Discussion started by: iarp
3 Replies
Login or Register to Ask a Question