Format txt file in UNIX


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Format txt file in UNIX
# 1  
Old 03-27-2014
RedHat Format txt file in UNIX

Hello All,

I have File_all.txt which have content as below

Code:
Volume in drive E is Data
 Volume Serial Number is 586D-6932

 Directory of E:\mydi2\siudfor\TFG058

03/27/2014  09:59 PM   5,569 FX\FX01      my4_pg4_MON_20140327_C.zip
               1 File(s)          5,569 bytes

 Directory of E:\mydi2\mydata1\SITLOV

03/27/2014  09:58 AM 317,885 FR1\usr1    mydata1_site_sk_20140325_c.zip
03/27/2014  09:58 PM 317,885 FR1\usr1    mydata1_inv_rk_20140325_1_c.zip
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lap_rk_20140325c.xlsx
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lol_rk_20140325_c.doc
03/27/2014  09:58 AM  176,860 FR1\usr1   mydata1_lol_rk_20140325_c.xls
               2 File(s)        494,745 bytes

     Total Files Listed:
               3 File(s)        500,314 bytes
               0 Dir(s)  53,174,284,288 bytes free

I want to process it and make a new file having only below information.

Code:
03/27/2014  09:58 AM 317,885 FR1\usr1    mydata1_site_sk_20140325_c.zip
03/27/2014  09:58 PM 317,885 FR1\usr1    mydata1_inv_rk_20140325_1_c.zip
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lap_rk_20140325c.xlsx
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lol_rk_20140325_c.doc
03/27/2014  09:58 AM  176,860 FR1\usr1   mydata1_lol_rk_20140325_c.xls
03/27/2014  09:59 PM   5,569 FX\FX01      my4_pg4_MON_20140327_C.zip

order of data in final file does not matter. I hope it is possible, somehow.
# 2  
Old 03-27-2014
For posted sample data:
Code:
awk '/^[0-9]/' File_all.txt

# 3  
Old 03-27-2014
Code:
$ grep 2014 infile.dat
03/27/2014  09:59 PM   5,569 FX\FX01      my4_pg4_MON_20140327_C.zip
03/27/2014  09:58 AM 317,885 FR1\usr1    mydata1_site_sk_20140325_c.zip
03/27/2014  09:58 PM 317,885 FR1\usr1    mydata1_inv_rk_20140325_1_c.zip
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lap_rk_20140325c.xlsx
03/27/2014  09:58 PM 176,860 FR1\usr1    mydata1_lol_rk_20140325_c.doc
03/27/2014  09:58 AM  176,860 FR1\usr1   mydata1_lol_rk_20140325_c.xls

# 4  
Old 03-27-2014
Hi,
Try:
Code:
grep '[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]' file_all.txt | sort

But in your file, just:
Code:
grep '/' file_all.txt | sort

Regards.
This User Gave Thanks to disedorgue For This Post:
# 5  
Old 03-27-2014
RedHat

Quote:
Originally Posted by disedorgue
Hi,
Try:
Code:
grep '[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]' file_all.txt | sort

But in your file, just:
Code:
grep '/' file_all.txt | sort

Regards.
If I want to append the content to another file how we can do that in same command.
and also some time we may get a file as below

Code:
Volume in drive E is Data
 Volume Serial Number is 586D-6932

in this case grep will show any error

---------- Post updated at 06:06 PM ---------- Previous update was at 05:20 PM ----------

Quote:
Originally Posted by disedorgue
Hi,
Try:
Code:
grep '[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]' file_all.txt | sort

But in your file, just:
Code:
grep '/' file_all.txt | sort

Regards.

there is one entry in file which i want to ignore during filter.
Code:
12/11/2013  11:26 AM    31,744 fr1\usr2        Thumbs.db


can we do that.

Last edited by kumar30213; 03-27-2014 at 07:27 PM..
# 6  
Old 03-29-2014
Quote:
Originally Posted by kumar30213
If I want to append the content to another file how we can do that in same command.
Code:
grep '...' file_all.txt | sort >> other_file

Quote:
and also some time we may get a file as below
Code:
Volume in drive E is Data
 Volume Serial Number is 586D-6932

in this case grep will show any error
What error does grep show?

Quote:
there is one entry in file which i want to ignore during filter.
Code:
12/11/2013  11:26 AM    31,744 fr1\usr2        Thumbs.db

can we do that.
Code:
grep '...' file_all.txt |grep -v "Thumbs.db" | sort >> other_file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help to format one txt file to required format

Hello Everyone, I have one source file which is genarated by SAP in different format(Which I've never seen). I need to convert that file to required format and I need to read this target file from Datastage to use this in my Jobs. So I do not have any other options except to use Unix script to... (4 Replies)
Discussion started by: Prathyu
4 Replies

2. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

3. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

4. Shell Programming and Scripting

Format txt file as html table

I have a short time to solve a problem, so I need some help. I've searched the forum, but I couldn't find a solution to my problem. I made a script to filter some text and now I have a new requirement to make it available as html table. Problem is that I more than one files with different set... (2 Replies)
Discussion started by: tetreb
2 Replies

5. Shell Programming and Scripting

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (2 Replies)
Discussion started by: Samtel
2 Replies

6. UNIX for Dummies Questions & Answers

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (1 Reply)
Discussion started by: Samtel
1 Replies

7. Shell Programming and Scripting

Format txt file to CSV

Hi All, I have a file with content FLIGHT PLANS PRODUCED ON 26.08.2008(SORTED BY FPLAN NUMBER) RUN DATED 27/08/08 PAGE 1 -------------------------------------------------------------- FPLAN FPLAN PRE BTCH BATCH POST BTCH BATCH BATCH ... (1 Reply)
Discussion started by: digitalrg
1 Replies

8. UNIX for Dummies Questions & Answers

Save Excel file as .txt in UNIX format

I have some files created in Excel that have to be saved as .txt files in order to load them into our accounting system. I can save the files as .txt files through Excel, but I then have to open them in TextPad and do a save as to change the Format from PC to UNIX. Is there a way to skip this step... (2 Replies)
Discussion started by: jroyalty
2 Replies

9. Shell Programming and Scripting

AWK CSV to TXT format, TXT file not in a correct column format

HI guys, I have created a script to read 1 column in a csv file and then place it in text file. However, when i checked out the text file, it is not in a column format... Example: CSV file contains name,age aa,11 bb,22 cc,33 After using awk to get first column TXT file... (1 Reply)
Discussion started by: mdap
1 Replies

10. Shell Programming and Scripting

How to format a txt file using typeset?

Hi all, i have a file toto.txt : blabla;toumtoudoum;blablabla toumtoudoumtoudoum;blabla;popopopo blablabla;etcetcetc;blabla etc.... As you can see, it is a simple file containig 3 fields separated by a ";". What i want to do is to display this file with a nice formating... (4 Replies)
Discussion started by: HowardIsHigh
4 Replies
Login or Register to Ask a Question