openSUSE Forums > Programming/Scripting » simple bash stuff

Go Back   openSUSE Forums > Programming/Scripting
Forums FAQ Members List Search Today's Posts Mark Forums Read


Programming/Scripting Questions about programming, bash scripts, perl, php, cron jobs, ruby, python, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 17-Sep-2009, 10:02
wakou's Avatar
Busy Penguin
 
Join Date: Feb 2009
Posts: 328
wakou hasn't been rated much yet
Default simple bash stuff

Apologies if this is not the right place!

Trying to force myself to use/learn cli more I decided to put all of my downloaded *.pdf files in their own dir. Instead of drag/drop in Konqueror, I decided to try in a konsole. So after a couple of bashes(!) I started thus:

stephen@linux-oqc9:~> md linux_tips

and then ls, all fine, new dir exists.

Then:

stephen@linux-oqc9:~> mv Documents/*.pdf linux_tips

and:

stephen@linux-oqc9:~> ls linux_tips
The "right" result, ie:
monitor.pdf wallchart.pdf zypper_cheat_sheet_p1_letter.pdf zypper_cheat_sheet_p2_letter.pdf
UserManual.pdf zypper_cheat_sheet_p1_a4.pdf zypper_cheat_sheet_p2_a4.pdf


So, then;,
stephen@linux-oqc9:~> kpdf linux_tips/zypper_cheat_sheet_p1_a4.pdf

and to my surprise, kpdf opened with the chosen document. I treated myself to a celebration cup of tea, and decided to track down any other *.pdf I have hiding away in my ~/

So;

stephen@linux-oqc9:~> locate ~/*.pdf
The result???
/home/stephen/Documents/monitor.pdf
/home/stephen/Documents/UserManual.pdf
/home/stephen/Documents/wallchart.pdf
/home/stephen/Documents/zypper_cheat_sheet_p1_a4.pdf
/home/stephen/Documents/zypper_cheat_sheet_p1_letter.pdf
/home/stephen/Documents/zypper_cheat_sheet_p2_a4.pdf
/home/stephen/Documents/zypper_cheat_sheet_p2_letter.pdf
/home/stephen/linux_starter_pack/linux_starter_pack.pdf


Now these files are showing that they are in their ORIGINAL locations!!!!
I went back to Konqueror, and the files are indeed in the new dir. Why does locate see them as still being in "Documents"? Also I have manually in Konq. found other *.pdf docs in ~/Desktop/DeskDocs, why did locate not find them?
__________________

Currently trying 11.2/kde4/2.6.31.5-0.1/nvidia 190.42
11.1: kernel 2.6.27.29-0.1-pae: kde 3.5.10: nVidia driver 180.51: Compiz 0.8.2 Single core Athlon, 2Gb RAM, nVidia 6150SE
Reply With Quote
  #2 (permalink)  
Old 17-Sep-2009, 10:20
FeatherMonkey's Avatar
Wise Penguin
 
Join Date: Mar 2008
Posts: 1,545
FeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura aboutFeatherMonkey has a spectacular reputation aura about
Default Re: simple bash stuff

Hehe now you have a new one look at using find .... man find but it has some really horrible syntax which takes some getting used to.

In regards to what you did locate uses a db to search which is why it can be quicker than find but as you experienced if it isn't updated it will report the old location.

To solve as root run updatedb iirc this is usually run as a cron job once a day.
__________________
Man first, have a try at Info, have a look at Wiki, if all that fails Scroogle!!!!!
If I've helped click on the Rep button I don't know what it does but it sounds cool.
Reply With Quote
  #3 (permalink)  
Old 17-Sep-2009, 10:24
wakou's Avatar
Busy Penguin
 
Join Date: Feb 2009
Posts: 328
wakou hasn't been rated much yet
Default Re: simple bash stuff

TY feather for the quick and informative reply! I had asumed that removing Beagle had disabled file indexing, obv. there is other ferreting going on!
Also I have manually in Konq. found other *.pdf docs in ~/Desktop/DeskDocs, why did locate not find them?
is ~/Desktop/ not indexed then?

PS I did the update, and now all is well, locate also found the other *.pdf, which seem to have been there since March. I guess I do not have any auto-update cron jobbies active at all?
__________________

Currently trying 11.2/kde4/2.6.31.5-0.1/nvidia 190.42
11.1: kernel 2.6.27.29-0.1-pae: kde 3.5.10: nVidia driver 180.51: Compiz 0.8.2 Single core Athlon, 2Gb RAM, nVidia 6150SE
Reply With Quote
  #4 (permalink)  
Old 17-Sep-2009, 10:25
microchip8's Avatar
Shaman Penguin
 
Join Date: Jun 2008
Location: /dev/belgium
Posts: 2,193
microchip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the roughmicrochip8 is a reputation jewel in the rough
Default Re: simple bash stuff

you shouldn't rely on locate since it's not a "real-time" program which constantly tracks changes on the file system but instead relies on a DB which needs updating with updatedb to have the newest changes in it.... find will be a better solution
__________________
My site: http://microchip.bplaced.net
My repo: http://download.opensuse.org/repositories/home:/microchip8
SUSE Unbound Forum: http://suseunbound.lefora.com


Do coders dream of sheep() ?
Reply With Quote
  #5 (permalink)  
Old 17-Sep-2009, 10:41
platinum
Guest
 
Posts: n/a
Default Re: simple bash stuff

wakou wrote:
> found other *.pdf docs in ~/Desktop/DeskDocs, why did locate not find them?


locate didn't find them because you put them there after updatedb ran?

--
platinum
Reply With Quote
Reply

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2