how do i remove the first 5 numbers from my data string ??
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
how do i remove the first 5 numbers from my data string ??
Hi,
I am trying to process twelve .csv files that contain 9 columns of 20,000 data points each.
I have got a piece of Fortran code to perform an FFT on this data and it runs.
I also have a Bash command file to run the FFT on all my data sets one after the other and output the results to a .dat file.
BUT i have a problem, the data does not open in excel so im trying to use gnuplot to produce graphs of the .dat files but the first column of my data is time and due to the logger used to take the data the time values have 12 digits. Of these 12 digits the first 5 are all the same so i wish to remove the first 5 digits from the string so that gnuplot is able to plot it as at the moment it is cutting off the last 2 digits which are the key ones.
Any help with this would be greatly appreciated!!
Please let me know if anything is not clear
hmmm ... my understanding is that it is the first 5 from each line and not from each field (maybe OP can clear that up). Also you do not indicate if the numbers start at the
beginning of the line or if there is possibly white space prior? (I will assume there is none)
So borrowing Daniel's example:
Code:
echo '123456789,123456789,123456789,123456789,123456789,123456789' | sed -r 's/^[0-9]{5}//'
... my understanding is that it is the first 5 from each line and not from each field ...
If that is the case, then maybe we need nothing fancier than ...
Code:
cut -c6- $InFile > $OutFile
Quote:
This will edit the file in place.
Not to quarrel with the guru, I always avoid editing an input file in place. I want to be able to run and re-run a program as my code evolves, always starting with the same input file. In other words, it is dangerous to tamper with evidence!
Not to quarrel with the guru, I always avoid editing an input file in place. I want to be able to run and re-run a program as my code evolves, always starting with the same input file. In other words, it is dangerous to tamper with evidence!
No probs, supply -i an extension:
Code:
sed -ri.bak 's/^[0-9]{5}//' file
Now you have the edited file called "file" and the old file stored in "file.bak"
And definitely no quarrel ... I learn something different every time I look at questions
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.