Manipulating Fields Of Flat File
I have a flat file and the data in it is having the following format.
4AGDA, 211, 51LN39, 4AGDI, 216, 15, 45ACCUNET Generic Digital Access Local Channels
(Only 1 row is shown).
This as you can see is a comma delimited file. I want to do the follwing manipulation.
Copy the last 4 characters from field1 (ie AGDA)
Copy the last 2 characters from field2 (ie 11)
Copy the last 5 characters from field3 (ie 1LN39)
Copy the last 4 characters from field4 (ie AGDI)
Copy the last 2 characters from field5 (ie 16)
Copy the last character from field6 (ie 5)
Leaving the first 2 characters and copying the rest of the data from field7 (ie 45ACCUNET Generic Digital Access Local Channels)
and then print the result in a new file. This is to be done for all the rows in that falt file.
Please help me with the commands or programming conceptsb to achieve the above functionality.
Thanks and Regards
look into sed (stream editor?) or awk (the initials of its creators).
They both manupilate text to do exactly what you need.
there are scripts you can write in C or in shell code that use simple math and for loops to remove just white space, 1 character from the front and so forth
they are 25- 50 lines long, not complicated,
usually for free
search yahoo for , C source code, shell script recipies, shell script file utilities, etc.
It's not Linux and look suspiciously like homework. Moved to General.
Another poster has already mentioned sed and awk, so I'll mention perl. Perl is perfectly suited to just this sort of bang together something quickly and manipulate text files.
Try running through this short tutorial: http://www.comp.leeds.ac.uk/Perl/start.html and you should know enough to bash (no pun intended) something together.
Alternatively you could do something with Excel/Calc/Gnumeric as well.
Heck, paypal me $20 and I'll do it for yah. . . unless this is your homework, then you have to do it yourself, yah slacker!
perl is good because it works on a shell, in UNIX anyway.
its a good utility language,
its a nice thing to learn
**pay attention to how you make calls to system resources,
be carefull with regular expressions
dont let a perl script run by itself as root when used on the Web....
do some research
what are you phishing for??
and are you trading it??
gee, are you a kiddie??
a cracker that calls himself a hacker??
i may be misunderstanding whats behind that screenname, but i dont think i am
I don't trade fish, but I do trade live Phish recordings as well as recordings of other jambands. In the past, I did this mostly through my ftp server and BnPs, although these days I'm using bittorrent as it is a much more efficient use of my time. All done legally, as Phish allows the trading of their audience recordings.
Not a kiddie, not a cracker (but I am caucasian), and my last hack was building a low impedence microphone to use with a harmonica and a guitar amp for less than $12 in parts from a local electronics shop.
Yes, I think you're misunderstand what's behind my screenname.
yes i guess i did,
im glad i did,
carefull though, i was easy to lead me to think other things
phish, the band, that wasnt my first thought.
it sounds as though you phish for info and sell it.
but hey the hack is nice!
yeah i agree, your not a script kiddie,
you seem to be a hacker in the traditional sense.
thats always encouraging.
i stand corrected.
|All times are GMT -5. The time now is 06:33 PM.|