File Extraction


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting File Extraction
# 1  
Old 05-05-2011
File Extraction

Hi,

I have three files as below:
Code:
AA.DAT20110505063903.Z
AA.DAT20110405062903.Z
AA.DAT20110305061903.Z

All the above files are appended with Date and timestamp in compressed format.

I need to extract AA.DAT20110505063903.Z(which is the latest file) from one server and uncompress it to AA.DAT before FTP'ing to different server.

Please let me know how to perform this using Script.

Thanks in advance
Sue

Moderator's Comments:
Mod Comment Please use [code] and [/code] tags when posting code, data or logs etc. to preserve formatting and enhance readability, thanks.

Last edited by zaxxon; 05-05-2011 at 09:21 AM.. Reason: code tags
# 2  
Old 05-05-2011
Code:
A=$(ls -1 AA.DAT*.Z| sort -k 1.7,1.14n| tail -1); compress -d $A; mv ${A%.*} $(echo $A| cut -c1-6)


Last edited by zaxxon; 05-05-2011 at 09:23 AM.. Reason: changed sed vs. cut
# 3  
Old 05-06-2011
Hi,

When i executed this command, i am getting last file instead of first file. Please help me out.

Thanks
Sue

---------- Post updated 05-06-11 at 02:17 AM ---------- Previous update was 05-05-11 at 08:40 AM ----------

Hi,

I could get the desired file by changing the code to
Code:
ls -1 .AADAT*.Z| tail -1

But when i am trying to execute the entire command
Code:
A = (ls -1 AA.DAT*.Z| tail -1); uncompress -d $A; mv ${A%.*} $(echo $A| cut -c1-6) i am getting  syntax error: `(' unexpected

Please assist me how to keep this in a script.

Note: Since I am a novice to scripting, I am really facing tough time to get used it.

Thanks
Sue

Last edited by Franklin52; 05-06-2011 at 06:40 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Data extraction from .xml file

Hello, I'm attempting to extract 13 digit numbers beginning with 978 from a data file with the following command: awk '{ for(i=1;i<=NF;i++) if($i ~ /^978/) print $i; }' datafile > outfile This typically works. However, the new data file is an .xml file, and this command is no longer working... (6 Replies)
Discussion started by: palex
6 Replies

2. Shell Programming and Scripting

FILE_ID extraction from file name and save it in CSV file after looping through each folders

FILE_ID extraction from file name and save it in CSV file after looping through each folders My files are located in UNIX Server, i want to extract file_id and file_name from each file .and save it in a CSV file. How do I do that? I have folders in unix environment, directory structure is... (15 Replies)
Discussion started by: princetd001
15 Replies

3. Shell Programming and Scripting

data extraction from a file

Hi Freinds, I have a file1.txt in the following format File1.txt I want to get 2 files from the above file filextra.txt should have the lines which are ending with "<" and remaining lines in the filecompare.txt file. Please help. (3 Replies)
Discussion started by: i150371485
3 Replies

4. Shell Programming and Scripting

problem with file content extraction

I need to extract some content of a file. Example file abc vi abc ooooooooo bbbbbbbbb vvv 1234 5 vvv 6789 3 xxxxxxxxxx xxxxxxxxxx i want to extract only the following content from file abc and store in another file say temp. 1234 5 6789 3 what should be my approach? (2 Replies)
Discussion started by: priya_ag04
2 Replies

5. Shell Programming and Scripting

File extraction without awk

Hello everybody, Here is my problem : I cannot find a way to extract data from a particular file and more precisely I cannot extract the result of my awk script to an external file because I am currently working on HP-UX. I would like a simple script (without awk) which asks for a date like... (4 Replies)
Discussion started by: freyr
4 Replies

6. Shell Programming and Scripting

data extraction from xml file

I have an of xml file as shown below <?xml version='1.0' encoding='ASCII' standalone='yes' ?> <Station Index="10264" > <Number Value="237895890" /> <Position Lat="-29.5" Lon="3.5" /> <MaxDepth Value="-4939" /> <VeloLines Count="24"> <VeloLine Index="0" > <Depth... (3 Replies)
Discussion started by: shashi792
3 Replies

7. Shell Programming and Scripting

Data Extraction From a File

Hi All, I have a requirement where I have to search the file with some text say "Exception". This exception word can be repeated for more then 10 times. Suppose the "Exception" word is repeated at line numbers say x=10, 50, 60, 120. Now I want to extract all the lines starting from x-5 to... (3 Replies)
Discussion started by: rrangaraju
3 Replies

8. UNIX for Dummies Questions & Answers

Flat File Extraction

Hi all, I'm new in the unix environment. I'm having a challenge in extracting data from a flat file and convert it to a CSV file format or I should be able to open it with MS Excel. The input data in my flat file looks like this: AV00001001155000063637143326711145412082EM SITHOLE... (3 Replies)
Discussion started by: Mthimbana
3 Replies

9. Shell Programming and Scripting

extraction of perfect text from file.

Hi All, I have a file of the following format. <?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="tomcat"/> <role rolename="role1"/> <role rolename="manager"/> <role rolename="admin"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user... (5 Replies)
Discussion started by: nua7
5 Replies

10. UNIX for Dummies Questions & Answers

help on file extraction

Hello, Im trying to extract a portion of a big file. Using unique pattern /occurrence , (ex. loginname1,logoff and loginname2,logoff ), I like to print the lines that contain the patterns and the lines between them. Also, create a file for every login occurrence. Thanks for everyone's... (1 Reply)
Discussion started by: apalex
1 Replies
Login or Register to Ask a Question