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.

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 :

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.

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.

1 Like

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!

I am working for a company and right now am working on project. I am new to linux shell scripting

read the man page for the cut comand paying attention to the field and delimiter options.

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?