ASIC/FPGA Design and Verification Out Source Services
Explanation to the e search script(first the simple version)
This page explains issues from: page up
- Note: To keep my scripts simple to develop, I usually use commands that I am familiar with and not always trying to be most efficient.
- In this script I decided to use xargs, because I use intensively in many other scripts.
#!/bin/bash
echo "================================================"
#if not all arguments are given
if [ $# -ne 2 ]
then
echo "wrong number of argument"
exit
fi
cat e_list_mod.txt | xargs -n1 | xargs -i= grep -$1 $2 =
- For a single word search a bash shell script is fine. Note that we only use the files from the e list. Those are piped to a grep command.
- This does not work if the search pattern includes spaces: i.e. more than one word.
- I did not want to investigate to much in the issue. So I come up with a simple idea. Create a PERL script, that in a non simple case, creates a separate script.
#!/bin/perl
#define an alias
#alias e_search "perl ~/bin/e_search.pl "
#Invocation Examples:
#e_search n "l_txbs : list of txb_u"
#e_search n "l_txbs"
print("================================================\n");
#if not all arguments are given
if($#ARGV != 1 ) {
$n=$#ARGV+1;
die("wrong number of argument $n $ARGV[0]\n");
}
if(index($ARGV[1], " ") >= 0) {
open(FPW, ">/home/RND/pinhask/bin/e_src.unx") || die("open fail /home/RND/pinhask/bin/e_src.unx\n");
print FPW ("grep -");
print FPW ("$ARGV[0] \"$ARGV[1]\" \$1\n");
close(FPW);
system("chmod u+x /home/RND/pinhask/bin/e_src.unx");
$cmd="cat e_list_mod.txt | xargs -n1 | xargs -i= /home/RND/pinhask/bin/e_src.unx =";
}
else {#simple case
$cmd="cat e_list_mod.txt | xargs -n1 | xargs -i= grep -" . $ARGV[0] . " " . $ARGV[1] . " =";
};
#die("$cmd\n");
system($cmd);
- So in the simple case, we simply do exactly what the bash script does.
- In the complex one, we create a script. The script uses the grep command as before and the pattern string match, is now embedded in it.
- An improved version of the PERL script is given below, in a txt file. Usually after doing a search, you may want to view results. So if you selected -l, the scripts prepares for you an executable script that fires the less command. It gives less the -p option with the search pattern.less to vi invocationNote to you can switch to vi from within less by hitting v.
- It is recommended to add the following alias:
alias e_less "~/bin/e_less.unx"
-
This is an example for the script that is generated by the
PERL script:
#!/bin/bash
#followed by a very long line
less -p "stop" /vobs/vlsi_msp/mpf/project_lib/bbn_env/e/bbn_expansion.e /vobs/vlsi_msp/mpf/project_lib/bbn_env/e/bbn_erm_units.e /vobs/vlsi_msp/mpf/project_lib/bbn_env/e/bbn_sb.e /vobs/vlsi_msp/mpf/project_lib/mmu/e/mmu_master_env.e /vobs/vlsi_msp/mpf/project_lib/avalon/e/avalon_header.e /vobs/vlsi_msp/mpf/project_lib/avalon/e/avalon_master_monitor.e /vobs/vlsi_msp/mpf/project_lib/avalon/e/avalon_slave_monitor.e /vobs/vlsi_msp/mpf/project_lib/tx/e/tx_structs.e /vobs/vlsi_msp/mpf/project_lib/tx/e/tx_env.e /vobs/vlsi_msp/mpf/project_lib/tx/e/tx_driver.e
-
The improved PERL script:
improved PERL script.
Contact me now at: |