How can link/redirection of a directory exclude certain dir - filesystems

How can link/redirection of a directory, e.g. by mount or ln -s, in case the directory links/redirects to its parent can exclude itself or certain directories else ?
ln -s just work for once entirely

Related

No such file or directory when there is one

I'm getting the error No such file or directory when trying to run the command find /home/backups/psono/backup -type d -mtime +5 -exec rm -rf {} \; although there are several directories inside the /home/backups/psono/backup directory. When I re-run the same command after the the first run, this time I don't receive any error message and the directories that are 5 days old (or older) are removed.
I'm trying to run this command from crontab and hence this question

Does the "%defattr" directive affect the "%post" section also in rpm spec file?

I have a .spec file with code somewhat like this:
%files
%defattr(-,xyz, xyz)
%verify(md5 size mtime mode) %attr(755, xyz, xyz) /usr/bin/app1
%verify(md5 size mtime mode) %attr(755, xyz, xyz) /usr/bin/app2
%post
mkdir -p /apps/1/logs
mkdir -p /apps/2/logs
mkdir -p /apps/3/logs
mkdir -p /apps/4/logs
mkdir -p /apps/5/logs
ln -sf /usr/bin/app1 /usr/bin/app3
touch /home/xyz/abc.log
will the %defattr also affect the default attributes of files and directories getting created in the post section??
No. You'll need to explicitly chown/chmod anything you do in %post. It's preferred to not have them in %post because things can break that way (like rpm -V). Why wouldn't you want that to be done in %build?

Shell script to remove files with no extension

I need a shell script to remove files without an extension (like .txt or any other extension). For example, I found a file named as imeino1 (without .txt or any other thing) and I want to delete them via shell script, so if any developer know about this part, please explain how to do it.
No finds, no pipes, just plain old shell:
#!/bin/sh
for file in "$#"; do
case $file in
(*.*) ;; # do nothing
(*) rm -- "$file";;
esac
done
Run with a list of files as argument.
Assuming you mean a UNIX(-like) shell, you can use the rm command:
rm imeino1
rm -rvf `ls -lrth|grep -v ".txt"`
ls -lrth|grep -v ".txt" should be inside back-quotes `…`(or, better, inside $(…)).
If other filenames are not containing "." then instead of giving .txt for grep -v, you can give
rm -rvf `ls -lrth|grep -v "."`
This will remove all the directories and files in the path without extension.
rm -vf `ls -lrth|grep -v "."` won't remove directories, but will remove all the files without extension (if the filename does not contain the character ".").
for file in $(find . -type f | grep -v '\....$') ; do rm $file 2>/dev/null; done
Removes all files not ending in .??? in the current directory.
To remove all files in or below the current directory that contain no dot in the name, regardless of whether the names contain blanks or newlines or any other awkward characters, you can use a POSIX 2008-compliant version of find (such as found with GNU find, or BSD find):
find . -type f '!' -name '*.*' -exec rm {} +
This looks for files (not directories, block devices, …) with a name that does not match *.* (so does not contain a .) and executes the rm command on conveniently large groups of such file names.

Required help in make file

i just want to implement below statement
"if bin folder is not available in current directory then make new bin folder &
if bin folder is available then its do nothing"
can anybody give me any idea how can i do this?
EDIT :
i dont want any error like
mkdir: cannot create directory `./bin `./bin': File exists
You can just do this:
-mkdir ./bin
If ./bin already exists then mkdir will fail silently, otherwise it will create the directory.
Use a rule like this:
bin:
mkdir bin
Then instead of writing mkdir bin as part of other rules, make them depend on the bin rule. The bin rule will only be executed if bin does not exist.
For your requirement you can use the rule as follows:
bindir:
if [ ! -d bin ];then \
mkdir bin; \
fi
Please note that if statement checks for existence of directory named bin in the current directory where makefile resides, if directory named bin does not exist then it will create it, if it exists it does nothing, but if there is a regular file (not a directory) with the name bin exists then this rule will fail.
Suggest you to use a variable say BINDIR to store the value of your "bin" directory as that is the general norm followed, it is good for maintenance of makefile.
BINDIR:=bin
bindir:
if [ ! -d $(BINDIR) ];then \
mkdir $(BINDIR); \
fi

Makefile - include library

I'm trying to write a module that uses the function nanosleep().
when my make file runs it changes the build libary by doing:
make -C /lib/modules/2.6.18-128.4.1.el5/build M=/workspace/lcd-winstar-0.0.1 modules
nanosleep is declare in /usr/include so my makefile cant find it.
what lines should I add to my makefile to include this location as well?????
thanks
-I dir
Add the directory dir to the list of directories to be searched for
header files. Directories named by -I
are searched before the standard
system include directories. If the
directory dir is a standard system
include directory, the option is
ignored to ensure that the default
search order for system directories
and the special treatment of system
headers are not defeated .
&&
-Ldir
Add directory dir to the list of directories to be searched for -l

Resources