# scripting for menu

**URL:** <https://community.unix.com/t/scripting-for-menu/152955>\
**Category:** Shell Programming and Scripting\
**Created:** [April 25, 2005, 11:34am UTC](https://community.unix.com/t/scripting-for-menu/152955 "2005-04-25T11:34:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu](https://community.unix.com/letter_avatar/manu/32/5_5575768a8748004e209b776fc1b2916d.png) [@Manu](https://community.unix.com/u/Manu)\
**Post date:** [April 25, 2005, 11:34am UTC](https://community.unix.com/t/scripting-for-menu/152955/1 "2005-04-25T11:34:37Z")

</div>

Hi,

I'm writting a script to filter a cvs log and get only the modified files to move them to a specific directory to compile.

I try to filter a line and move from source to target, with no results. Could you help me?

for example, in the cvs log file appears:  
cat log.txt  
U project/FOLDER1/FOLDER2/org/com/package/date/file.java  
P project/FOLDER1/FOLDER2/properties/file.properties

And I'd like an ouput file like this:  
cat solution.txt  
cp -Rfp project/FOLDER1/FOLDER2/org/com/package/date/file.java temp/classes/  
cp -Rfp project/FOLDER1/FOLDER2/properties/file.properties /temp/properties/

any idea?

I thought about join 2 filtered files, but when try to do a "cat -b" only join from 1 to 9 lines.

I have somethink like that:

echo "Step 1: Sorting only 'P' , 'C' and 'U' lines from cvs export"  
sorting.sh $1  
echo "Step 2: Cutting 2 first chars to get line"  
if [[-r 1.temp]]; then  
{  
cut -f5- -d \/ 1.temp \> 2.temp  
cut -b3- 1.temp \> 2b.temp  
cat -b 2.temp \> 2d.temp  
cat -b 2b.temp \> 2e.temp  
join 2e.temp 2d.temp \> 2c.temp  
#cut -b2- 2c.temp \> prepare.temp  
echo "Step 3: Substitute the string for deployment structure"  
#filters.sh prepare.temp  
echo "Applying modes and executing ..."  
#sort filtered.temp | uniq \> exec.temp  
#chmod +x exec.temp  
#exec.temp  
echo "Removing temp files"  
#rm \*.temp  
};  
fi  
echo "Done!"

Thanks in advance,

---

<div class="post-metadata">

**Author:** ![Just\_Ice](https://community.unix.com/user_avatar/community.unix.com/just_ice/32/165_2.png) [@Just\_Ice](https://community.unix.com/u/Just_Ice)\
**Post date:** [May 2, 2005, 1:58pm UTC](https://community.unix.com/t/scripting-for-menu/152955/2 "2005-05-02T13:58:12Z")

</div>

try this one ... (you might need to add another \ to the "$2" on the awk line) ...

```nohighlight
#!/bin/ksh
for TYPE in U P
do
    awk "/^${TYPE}/ {print \$2}" cvs.log > ${TYPE}.tmp
    if [-s ${TYPE}.tmp]
    then
          case ${TYPE} in
          U) TMPDIR=/temp/classes ;;
          P) TMPDIR=/temp/properties ;;
          esac
          for FILE in `< ${TYPE}.tmp`
          do
               cp -Rfp ${FILE} ${TMPDIR}
          done
     else
          echo "${TYPE} not found in cvs.log"
     fi
done

exit 0

```

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [May 2, 2005, 2:17pm UTC](https://community.unix.com/t/scripting-for-menu/152955/3 "2005-05-02T14:17:14Z")

</div>

nawk -f manu.awk log.txt | sh

here's manu.awk:

```nohighlight
$1 == "U" { dst = "temp/classes"}
$1 == "P" { dst = "/temp/properties"}
$1 == "P" || $1 == "U" { printf("cp -Rfp %s %s\n", $2, dst) }

```
