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.
I have thousands of *.txt files which using an command line program can translate them from Greeks to Swahili. Then I emailed them to others volunteers in central Africa and they print them in plain A4 papers and give them to local schools. So children can have access to knowledge...
The problem is that if a line starts with number , program skip that line and not translate it.
example:
Code:
1. blabla 1234
2. blabla 1234
etc
I need a command (sed -i... ?) for the .txt file to remove numbers only if a line start with number.Not all the numbers in txt file.
to be like this:
Code:
. blabla 1234
. blabla 1234
or to replace the number if line start with number with something else that will not break translation program
assume:
There is a Perl-base utility called rename which can process file names using full Perl regular expression pattern matching and indeed even full Perl expressions. It is part of the package "rename". Watch out, there is another utility with the same name but fewer capabilities.
Code:
rename -n -v 's/^\d+\.\s+//' *.txt
You can use the -n option for a dry run. See "man rename" for the details.
Last edited by Turbocapitalist; 03-07-2023 at 03:55 AM.
sorry for my english... i will try to make it clear.. i hope.
i have this example.txt
Code:
1. Οι μεταφράσεις χρειάζονται επιβεβαίωση από κάποιον γνώστη της γλώσσας Σουαχίλι. 1234
2. Για την ώρα έχουμε μια αυτόματη μετάφραση κάποιου προγράμματος και ενδέχεται να υπάρχουν αστοχίες ίσως και σοβαρές.
4. Είναι όμως μια αρχή κι αυτό... 1234
23. Όποιος μπορεί να διορθώσει και έχει τη γνώση και (1-3) τη διάθεση ας το κάνει, παρακαλώ να με ενημερώνει να διορθώνω κι εγώ εδώ τα κείμενα.
and i want to make it like this
Code:
. Οι μεταφράσεις χρειάζονται επιβεβαίωση από κάποιον γνώστη της γλώσσας Σουαχίλι. 1234
. Για την ώρα έχουμε μια αυτόματη μετάφραση κάποιου προγράμματος και ενδέχεται να υπάρχουν αστοχίες ίσως και σοβαρές.
. Είναι όμως μια αρχή κι αυτό... 1234
. Όποιος μπορεί να διορθώσει και έχει τη γνώση και (1-3) τη διάθεση ας το κάνει, παρακαλώ να με ενημερώνει να διορθώνω κι εγώ εδώ τα κείμενα.
or like this
Code:
*. Οι μεταφράσεις χρειάζονται επιβεβαίωση από κάποιον γνώστη της γλώσσας Σουαχίλι. 1234
*. Για την ώρα έχουμε μια αυτόματη μετάφραση κάποιου προγράμματος και ενδέχεται να υπάρχουν αστοχίες ίσως και σοβαρές.
*. Είναι όμως μια αρχή κι αυτό... 1234
*. Όποιος μπορεί να διορθώσει και έχει τη γνώση και (1-3) τη διάθεση ας το κάνει, παρακαλώ να με ενημερώνει να διορθώνω κι εγώ εδώ τα κείμενα.
perl rename in Slackware named rename.pl , i installed it but I think its only for renaming files name only.
I think sed -i is more close what i need , but I cant make it work... as i need.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.