Not able to create ctags in linux - ctags

I am getting following error after executing "ctags -R".
Command-
pihu#sc[/opt/soe/projects/sr_4k_10_1_x/pihu/sr1] >ctags -R
Output-
/opt/tools/unsupported/bin/ctags: no input files specified.
Try `/opt/tools/unsupported/bin/ctags --help' for a complete list of options.
Command-
pihu#sc[/opt/soe/projects/sr_4k_10_1_x/pihu/sr1] >which ctags
Output-
/opt/tools/bin/ctags
Additional Information-I used two file .bashrc and .cshrc in /home/pihu path.
.bashrc :-
export PS1="\u#\h\w>"
alias 2k4k='cd /opt/soe/projects/sr_4k_10_1_x/pihu'
alias avm='cd /opt/soe/projects/sr_4k_10_1_x/pihu'
export PATH=$PATH:/opt/tools/unsupported/bin:/opt/tools/bin:/tiara/local/bin:/opt/unsupported/bin:/opt/soe/lb/sr_lbtools/bin:/opt/soe/lb/sr_lbtools:/opt/soe/lb/sr_lbtools/tiara/local/bin:/usr/bin/

For the -R (recurse) option, you still have to supply a path:
ctags -R .
I always prefer to generate the list of files that I want to use first. Something like this:
find . -name *.c -type f > cscope.files
find . -name *.h -type f >> cscope.files
Then I run ctags with the -L option, like this:
ctags -L cscope.files

Append the dot to the ctags command:
ctags -R .

Related

Using fish shell builtins with find exec

I'm trying to source a file that I can get from the output of find using these commands:
find ./ -iname activate.fish -exec source {} \;
and
find ./ -iname activate.fish -exec builtin source {} \;
But both these commands give the error of the form find: ‘source’: No such file or directory or find: ‘builtin’: No such file or directory. Seems like exec of find is not able to recognize fish's builtins ?
What I basically want to achieve is a single command that will search for Python's virtualenv activate scripts in the current directory and execute them.
So doing something like -exec fish -c 'source {}; \ would not help. I've tried it as well and it doesn't error out but does not make the changes either.
Any ideas what can be done for this ?
Thanks!
Perhaps you need:
for file in (find ./ -iname activate.fish)
source $file
end
# or
find ./ -iname activate.fish | while read file
source $file
end
Command substitution executes the command, splits on newlines, and returns that list.
As mentioned in comments, seems like -exec does not run in or affect the current shell environment. So find -exec is not gonna work for my use case.
Instead, this will work:
source (find ./ -iname activate.fish)

How to search with find above your directory?

A part of the script make this:
dir_year=2017
dir_archive=/home/user/Documents/0_#Archivo
bindir=/home/user/bin
filework=out.txt
find "$dir_archive/$dir_year/" -name *.md > ${bindir}/${filework}
But it gives me an error since find does not look in top directories. The script is in/home/user/Documents/0_ # File/2017/script-directory.
For it to work I have to do:
cd "$dir_archive/$dir_year/"
find "$dir_archive/$dir_year/" -name *.md > ${bindir}/${filework}
Is there any way I do not need the cd command?
Thanks
It must be:
-name '*.md'
otherwise *.md would be expanded by the shell

Remove all non-numeric characters in a file name

I have a large number of files that are named in the format: ABC_XYZ_123.jpg.
I want to rename them in bulk so that I can get the format: 123.jpg.
How can I do this on a Mac?
Thanks!
Using find in terminal:
find . -type f -name "*_*_*.jpg" -execdir bash -c 'mv "$0" "${0##*_}"' {} \;
Would result in:
ABC_XYZ_123.jpg -> 123.jpg
Because I can never remember the command lines of the stools that specialize on this kind of stuff (like rename) I create a bash script that does the task:
$ ls > x.sh
$ vi x. sh
Within VI:
:%s/^[a-z_]*\(.*\)$/mv \0 \1/`
and then:
$ source x.sh
rename can do the likes, but, as I said, I've never bothered to learn it.
$ brew install rename

How to find and delete a particular file every directory using linux command

I'm using ubuntu 15.10. I have "backup_old.zip" file in more than 100 directories. How can I remove all "backup_old.zip" file in single linux shell command.
This shell command was worked for me.
$ find . -name backup_old.zip -type f -exec rm -r {} \;
You can use rm command to remove files.
rm -f */backup_old.zip

bash, "make clean" in all subdirectories

How can I find every Makefile file in the current path and subdirs and run a make clean command in every occurance.
What I have till now (does not work) is something like:
find . -type f -name 'Makefile' 2>/dev/null | sed 's#/Makefile##' | xargs -I% cd % && make clean && cd -
Another option would be to use find with -execdir but this gives me the issue with $PATH : The current directory is included in the PATH environment variable, which is insecure in combination with the -execdir action of find ....
But I do not want to change the $PATH variable.
An answer using the tools I used would be helpful so that I can understand what I do wrong,
but any working answer is acceptable.
Of course find is an option.. My approach with that would be more like:
find . -name Makefile -exec bash -c 'make -C "${1%/*}" clean' -- {} \;
But since you're using bash anyway, if you're in bash 4, you might also use globstar.
shopt -s globstar
for f in **/Makefile; do make -C "${f%/*}" clean; done
If you want to use the execution feature of find you can still do this:
find "${PWD}" -name Makefile -exec sh -c 'cd "${0%Makefile}" && make clean' {} \;
I would use the following approach:
find "$(pwd)" -name Makefile | while read -r line; do cd "$(dirname "$line")" && make clean; done
Please note the find $(pwd) which gives the full path as output of find.

Resources