Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
If using ext3, enable its b-tree feature. It should speed up searching. Another way is contribute to slocate to include an option to search by file and directory types. The find utility is the normal search tool. slocate is a database search tool that needs to be updated when files or directories are created or moved.
prints the directory name first and then symlinks in the directory
I have never seen syntax like this before---I assume that "|" is escaped so it won't act as a pipe, but then what does it mean? (Alternation operator?)
backreference!!--a little bell is ringing---is this a backreference?
Note that this prints ALL the directories in the search path, plus the links it find in each one. I guess you could then write more code to strip out the one's which contain no links......
I have never seen syntax like this before---I assume that "|" is escaped so it won't act as a pipe, but then what does it mean? (Alternation operator?)
backreference!!--a little bell is ringing---is this a backreference?
I dont think this is not a backreference. It just a simple OR in bash (although I may be wrong!!)
Quote:
Originally Posted by pixellany
Note that this prints ALL the directories in the search path, plus the links it find in each one. I guess you could then write more code to strip out the one's which contain no links......
this bash script should do the job perfectly. the script takes the search directory as agrument. Tell me what you think. I know this can be made better, but this is what I could think off top of my head.
Code:
#!/bin/bash
IFS=$'\n'
prevLine=
printDir=
for line in `ls -lR $1 |grep "^l\|:$" ` ; do
if [ -z $prevLine ] ; then
prevLine=$line
else
if [ "${prevLine:$((1-2))}" == ":" ] && [ "${line:0:1}" == "l" ]; then
if [ -z $printDir ]; then
echo $prevLine
printDir=printed
fi
echo $line
else
prevLine=$line
printDir=
fi
fi
done
I guess is is OR in gnu grep, (although I may be wrong!)
Happy Penguins!
You guess right---they actually call it the "alternation operator". I was being dense in that post....the code was obvious once I thought about it. (":$" means ":" at the end of the line. "|" is escaped because it is parentheses to keep bash from seeing it as a pipe--except that the quotes mean "read literally"--hence the escape to give special meaning to "|" (but a different special meaning than if it had be left unquoted...) )
Whew!!!---just one example of why shell scripting takes a few days to learn....
Raise your hand if you: A) had a vacuum tube collection in HS, B) know what IS a vacuum tube, C) know what is (was) magnetic core memory, D) know what is(was) an IBM keypunch, or E) know how to build radios with acid-core solder
I do not know how to raise hand here, however
A) No.
B) No.
C) Yes, it used to be state-of-art, space occupying heavy industry product. Several KB (kilo bit??) range.
D) Yes, it was Important Bunch of Machine for key-puncher. One card (boarding pass size) per one line. No backspace, delete keys.
E) Yes. Some of these radios work without external battery. Coil, variable condenser, antenna, ear piece and crystal. (http://en.wikipedia.org/wiki/Crystal_radio)
this bash script should do the job perfectly. the script takes the search directory as agrument. Tell me what you think. I know this can be made better, but this is what I could think off top of my head.
Code:
#!/bin/bash
IFS=$'\n'
prevLine=
printDir=
for line in `ls -lR $1 |grep "^l\|:$" ` ; do
if [ -z $prevLine ] ; then
prevLine=$line
else
if [ "${prevLine:$((1-2))}" == ":" ] && [ "${line:0:1}" == "l" ]; then
if [ -z $printDir ]; then
echo $prevLine
printDir=printed
fi
echo $line
else
prevLine=$line
printDir=
fi
fi
done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.