Login or Register to Ask a Question and Join Our Community


Need to extract 8 characters from a large file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to extract 8 characters from a large file.
# 1  
Old 12-19-2017
Need to extract 8 characters from a large file.

Hi All!!

I have a large file containing millions of records. My purpose is to extract 8 characters immediately from the given file.
Code:
222222222|ZRF|2008.pdf|2008|01/29/2009|001|B|C|C
222222222|ZRF|2009.pdf|2009|01/29/2010|001|B|C|C
222222222|ZRF|2010.pdf|2010|01/29/2011|001|B|C|C
222222222|ZRF|2011.pdf|2011|01/29/2012|001|B|C|C
222222222|ZRF|2012.pdf|2012|01/29/2013|001|B|C|C
222222222|ZRF|2013.pdf|2013|01/29/2014|001|B|C|C
222222222|ZRF|2014.pdf|2014|01/29/2015|001|B|C|C
222222222|ZRF|2015.pdf|2015|01/29/2016|001|B|C|C

So, my OUTPUT would be as under :

Code:
222222222
222222222
222222222
222222222

and so on.....

Please Help with Backup Shell Script. Thanks in advance

---------- Post updated at 02:52 PM ---------- Previous update was at 02:44 PM ----------

This is not a homework. This is the one got an error

---------- Post updated at 02:54 PM ---------- Previous update was at 02:52 PM ----------

@Scott and @Rudic tryto understand this is not a homework.

Last edited by Scott; 12-19-2017 at 03:20 PM.. Reason: Added code tags
# 2  
Old 12-19-2017
I've move this thread from "How to Post in the The UNIX and Linux Forums". Please stop posting technical questions in that forum.

Please post what you've tried so far, in code tags.
This User Gave Thanks to Scott For This Post:
# 3  
Old 12-19-2017
Quote:
Originally Posted by pavand
.
.
.
@Scott and @Rudic tryto understand this is not a homework.
As much as I'd like to believe you, that'd be difficult looking at your below quote. The problem is similar, and the sample data are identical.

Please explain in detail why and how this is NOT homework, like the company you work for, the project your work on, and / or the problem background or reasoning behind. Seriously, persuade us, don't try kidding us!


Quote:
Originally Posted by pavand
I have a homework and I tried to work on this but unable to find the solution. Can someone help me how to resolve the issue.

I have a package file and it contains text file as prod.ame300_000001.101414145111.A.txt.
In the text file it contains pdf file (222222222|ZRF|2008.pdf|2008|01/29/2009|001|B|C|C)
.
.
.
# 4  
Old 12-19-2017
I am working for a company and right now am working on project. I am new to linux shell scripting
# 5  
Old 12-19-2017
read the man page for the cut comand paying attention to the field and delimiter options.
# 6  
Old 12-20-2017
Hi pavand...

Before asking for help get you output requirements correct first.

You OUTPUT shows 4 lines of 9 characters, (ALL identical?), instead of 8 lines of 8 characters, (ALL identical?).

How can we possibly know which line of the first 8 OR 9 characters are needed when they all identical, or am I missing something?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Command to extract empty field in a large UNIX file?

Hi All, I have records in unix file like below. In this file, we have empty fields from 4th Column to 22nd Column. I have some 200000 records in a file. I want to extract records only which have empty fields from 4th field to 22nd filed. This file is comma separated file. what is the unix... (2 Replies)
Discussion started by: rakeshp
2 Replies

2. UNIX for Dummies Questions & Answers

Extract spread columns from large file

Dear all, I want to extract around 300 columns from a very large file with almost 2million columns. There are no headers, but I can find out which column numbers I want. I know I can extract with the function 'cut -f2' for example just the second column but how do I do this for such a large... (1 Reply)
Discussion started by: fndijk
1 Replies

3. Shell Programming and Scripting

Curl download zip extract large xml file

Hi i have a php script that works 100% however i don't want this to run on php because of server limits etc. Ideally if i could convert this simple php script to a shell script i can set it up to run on a cron. My mac server has curl on it. So i am assuming i should be using this to download the... (3 Replies)
Discussion started by: timgolding
3 Replies

4. Shell Programming and Scripting

Extract information into large variable

Hello people :) That's here my first message to your forum, so I guess it would be fine ^^ I have a request about a code I want to use. Actually, my system use a large variable, including much informations but those informations can change by more and I want to extract one of thoses... (26 Replies)
Discussion started by: WolwX
26 Replies

5. Shell Programming and Scripting

extract last 8 characters from a file name

Dear gurus I have several files with the following format filenameCCYYMMDD , that is the last 8 characters will be the date in CCYYMMDD format. eg FILENAME20110523 . Could anyone please put me through on how to extract only the last 8 characters from the files. I am thinking of using awk,sed... (2 Replies)
Discussion started by: erinlomo
2 Replies

6. Shell Programming and Scripting

extract characters from file name - script

trying to extract the numbers in this file name: fname="ebcdic.f0633.cmp_ebcdic.f0633.bin" fnametmp=${fname#*(V|v|F|f)} parse=${fnametmp%%(ENC|enc|CMP|cmp|BIN|bin)}} echo FLRECL=$parse result is FLRECL=0633.cmp_ebcdic.f0633 expected result FLRECL=0633 my guru is on holiday and i need... (5 Replies)
Discussion started by: mambo2523
5 Replies

7. Shell Programming and Scripting

extract unique pattern from large text file

Hi All, I am trying to extract data from a large text file , I want to extract lines which contains a five digit number followed by a hyphen , like 12345- , i tried with egrep ,eg : egrep "+" text.txt but which returns all the lines which contains any number of digits followed by hyhen ,... (19 Replies)
Discussion started by: shijujoe
19 Replies

8. Shell Programming and Scripting

Extract data from large file 80+ million records

Hello, I have got one file with more than 120+ million records(35 GB in size). I have to extract some relevant data from file based on some parameter and generate other output file. What will be the besat and fastest way to extract the ne file. sample file format :--... (2 Replies)
Discussion started by: learner16s
2 Replies

9. Shell Programming and Scripting

Need to extract 7 characters immediately after text '19' from a large file.

Hi All!! I have a large file containing millions of record. My purpose is to extract 7 characters immediately after text '19' from this file (including text '19') and save the result in new file. So, my OUTPUT would be as under : 191234561 194567894 192789005 198839408 and so on..... ... (7 Replies)
Discussion started by: parshant_bvcoe
7 Replies

10. Shell Programming and Scripting

Extract large list of substrings

I have a very long string (millions of characters). I have a file with start location and length that is thousands of rows long: Start Length 5 10 16 21 44 100 215 37 ... I'd like to extract the substring that corresponds to the start and length from each row of the list: I tried... (7 Replies)
Discussion started by: dcfargo
7 Replies
Login or Register to Ask a Question

Featured Tech Videos