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.
The problem I'm facing is I want to remove just the last comma such that the file retains all number and commas minus the last one. I am brain farting after GOOGLING all night .... I saw much reference to 'chomp' and 'chop' using PERL, but I'm trying to keep this very simple.
Is there a command in Linux that can be used or included in a simple script to remove this last character (the comma) from the file?
Any information or pointers are greatly appreciated!!!
It works for me. Thanks for your kind help. Can you explain that syntax for me please.
awk -F"/" '{$NF=""}1' OFS="/" file
what is $NF and OFS ?
Another question i am running find command on the directory. I am getting list of files created or modified in last 24 hours through following command.
find testdir -mtime -1 -type f -print >> images.log
where testdir have 20 subdirectories and each subdirectory have more than 1 directories beneath. So my command took lot of time consuming resources extensively because it has to search in every directory and beneath. I have two questions in mind.
1) What should be the command to search for files created or modified in last 12 hours.
2) What Should be the less expensive command to search means can i search through timestamp for files in last 24 hours ? Like
find . -name -mtime mm hh date mm:ss type -f > test.txt
Let suppose how could i find today(Apr 10) files through this command ?
The sed command was just another solution to the previous issue. To find files more recent than a specific date, you can create a dummy file using the touch command with the -t option, e.g:
My question is find should not work on entire directory as it will take lot of time and increases I/O. Is there any command that directly work on month. Like find search files which are created or modified in month April
directly and escape other files without looking into them.
Nope. The find command must look at every single item under the search path to see if it matches the search criteria. If you have billions of files under the search path, it will look at them all. No chance to skip some check in my opinion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.