LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2007, 07:15 AM   #1
Ejdaha
Member
 
Registered: Jan 2007
Posts: 39

Rep: Reputation: 15
Find a file


Hi all
I'm newbie in Linux. I want to find some file on whole Linux file system.

And I want to export some environment variables every time I connect to session
Where I must put this code?

Thanks...
 
Old 01-05-2007, 07:27 AM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Can't really help with the environment variables, but to find a file, open up a terminal and type:
Code:
find / -iname file_you_want_to_find
the first bit calls find (the program) the / indicates the root directory, and will search all folders therein, the third part (-iname) tells find to search for files by name, and to ignore the case of the search string/filename. Finally, the last part (file_you_want_to_find) is what you're searching for

Hope this helps.
 
Old 01-05-2007, 07:29 AM   #3
tshrinivasan
Member
 
Registered: Jan 2006
Location: Chennai, Tamil nadu, India
Distribution: Debian Etch Testing
Posts: 117

Rep: Reputation: 16
Hi Ejdaha,

Welcome to the real world.

"find" itself is the command
man find
will tell you more

ex
#find / -name "test.txt"

there are more options in find.
as finding by name,regular expressions, size, date, file type etc.
man find will help u more.

for environment variables, put them in /etc/profile as root.
This is the common file for all users.

~/.bash_profile is for particular users.
 
Old 01-05-2007, 07:42 AM   #4
Ejdaha
Member
 
Registered: Jan 2007
Posts: 39

Original Poster
Rep: Reputation: 15
Thank you very very much
 
Old 01-05-2007, 07:43 AM   #5
Bruce Hill
HCL Maintainer
 
Registered: Jun 2003
Location: McCalla, AL
Distribution: Funtoo
Posts: 6,926

Rep: Reputation: 128Reputation: 128
find / -iname '*wordperfect*' 2>/dev/null

substitute your file for wordperfect
 
Old 01-05-2007, 08:32 AM   #6
Broder
Member
 
Registered: Oct 2006
Location: Santa Barbara, C.A.
Distribution: Mood dependent
Posts: 117

Rep: Reputation: 15
I also like locate:
locate filename
 
Old 01-05-2007, 08:46 AM   #7
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by Feelda
I also like locate:
locate filename
If you use locate, you may need to first run updatedb as root.
 
Old 01-14-2007, 09:34 PM   #8
yuubouna
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Rep: Reputation: 1
hello,
what do you mean [/dev/null] ?

yuubouna
 
Old 01-14-2007, 09:56 PM   #9
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
/dev/null is a special file which sounds silly, but turns out to be very useful. If you write into /dev/null, nothing happens at all - the data just falls though a wormhole in space and time, forever to vanish from the universe.

This seems pretty useless, but it turns out a lot of the time, the output of programs you run on the command line splurge out all sorts of useless information which you might want to ignore. You can do this by re-directing the output to /dev/null.

For example (the $ denotes commands you enter in the shell, other lines what is output by those commands):
Code:
$ echo "This is annoying output"
This is annoying output
$ echo "This is annoying too" > /dev/null
Most programs produce output on two file handles, standard output and standard error. Standard output is usually used for legitimate output of a program, and standard error for error messages and debugging. For example if you execute "ls", the regular output is on standard output, and the errors on standard error.

By default both of these print to your terminal window. For example:
Code:
$ ls -d /var /etc /notexisting /alsonotexisting
ls: /notexisting: No such file or directory
ls: /alsonotexisting: No such file or directory
/etc  /var
What we see here is the error messages AND the proper output. If you're using bash, or another borne style shell (typical for modern Linuxes), you can re-direct these two outputs separately. For example, we can say that we don't want to see the proper output by redirecting it to /dev/null. This is done with the > symbol:
Code:
$ ls -d /var /etc /notexisting /alsonotexisting > /dev/null
ls: /notexisting: No such file or directory
ls: /alsonotexisting: No such file or directory
(note the lack of the line showing the /etc and /var directories).

Similarly, we can choose to re-direct the standard error with 2>
Code:
$ ls -d /var /etc /notexisting /alsonotexisting 2> /dev/null
/etc  /var
Just as a useful note: Each file handle which a program has open has a number. Standard output has the number 1, standard error has the number 2. ">" is in fact an abbreviation of "1>". There is one other file handle open for most processes - number 0 which is standard input. This is typically connected to some file from which a program reads, the user's keyboard (yes, you can type input directly into most programs), or the previous command in a pipeline.

Last edited by matthewg42; 01-14-2007 at 09:58 PM.
 
Old 01-14-2007, 11:20 PM   #10
natureday
LQ Newbie
 
Registered: Jan 2007
Location: WA state in the US
Posts: 6

Rep: Reputation: 0
You just need to find the root folder
Anna
 
Old 01-15-2007, 12:37 AM   #11
yuubouna
LQ Newbie
 
Registered: Jan 2007
Posts: 10

Rep: Reputation: 1
thanks a many matthewg42!
how about this one?

iconv -f Shift_JIS -t UTF-8 ${basename} > /dev/null/

does this convert encoding from original FileName to the same FileName?

Pardon me, for not being related to this thread..
yuubouna(^_-)-☆
 
Old 01-15-2007, 01:12 AM   #12
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Quote:
iconv -f Shift_JIS -t UTF-8 ${basename} > /dev/null/

does this convert encoding from original FileName to the same FileName?
You should remove the trailing / from /dev/null - it is not proper and will lead to an error. Assuming you do, this is what will happen:

It will convert from the Shift_JIS character encoding to UTF-8 encoding. It will read input from the file whose name is stored in the variable "basename". Since no output file is specified with the -o option, output will be written to standard output, which is then re-directed to /dev/null (i.e. it is discarded). The original file will not be modified.

Note that iconv, in common with many of the Unix command line programs, iconv does not respond well to outputting to the file which is also the input file - doing this will just leave you with an empty file. Instead you should re-direct your output to another filename - perhaps using the same name as the original with a .utf8 suffix, as shown below. If you wish, you may then move the new file "over" the original, erasing it.

In this example I do not use a variable to store the name of the input file - it is simply called "my_file", and is assumed to contain valid Shift_JIS encoded text:
Code:
iconv -f Shift_JIS -t UTF-8 my_file > my_file.utf8
If you wish to replace the original file with the new one, you just need to mv it. This is like rename. Be cautious though - mv will overwrite the original without prompting you "are you sure" (unless you have mv aliases to include the -i option):
Code:
mv my_file.utf8 my_file
Re-direction is also harsh. By default it will replace files without asking you. There is a way to make the shell more cautious about "clobbering" files with re-direction, but this is seldom enabled. Be careful.

To a command-line newcomer, it's a little scary that commands will silently overwrite files without prompting you "are you sure" at every turn. I suppose the rationale is that if you can be bothered to type a command, you should know what you want. This becomes a benefit to productivity once you know what you're doing despite the initial hesitation it sometimes causes. It also means users don't get conditioned into just replying "yes" to every prompt without reading them (enable macros in this word document anyone?).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find the file over mounten file system Wallace740 Linux - Newbie 2 03-30-2005 03:46 AM
Linker problem: can't find a file, but the file exists atlep Programming 5 08-16-2004 07:15 AM
how to find the file ld.so.1 cwmould Linux - Software 1 07-30-2004 05:41 AM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 11:34 PM
where can I find grammar file and lex file of GNU c ? thinks Huiming Linux - Software 1 06-11-2004 08:38 AM


All times are GMT -5. The time now is 05:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration