Results 1 to 4 of 4
hi,
i m getting segmentation fault on the 25th line could any one help me with it
#!/bin/sh -f
dir=$(date +%d-%m-%y)
echo $dir
Y=$(find ./$dir -type d|wc -l)
if [ ...
- 12-07-2007 #1Just Joined!
- Join Date
- Dec 2007
- Location
- bangalore
- Posts
- 38
segmentation fault
hi,
i m getting segmentation fault on the 25th line could any one help me with it
#!/bin/sh -f
dir=$(date +%d-%m-%y)
echo $dir
Y=$(find ./$dir -type d|wc -l)
if [ $Y -eq 0 ];then
mkdir $dir
fi
name=$1
arg=$@
echo $arg
echo $name
suffix=_0
suffix1=_
X=$(find ./$dir -type f|grep $name$suffix*|wc -l)
ROBIN=$X
echo $ROBIN
echo $X
if [ $ROBIN -lt 9 ];then \
ROBIN=`expr $ROBIN + 1`; touch ./$dir/$name$suffix$ROBIN.csv; ./card ./$dir/$name$suffix$ROBIN.csv $arg
else
ROBIN=`expr $ROBIN + 1`; touch ./$dir/$name$suffix1$ROBIN.csv
./card ./$dir/$name$suffix1$ROBIN.csv $arg
fi
find ./$dir -type f -printf '%f %c\n'|grep $name$suffix*|sort -rk5|awk '{print $1}'
- 12-07-2007 #2Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
- 12-07-2007 #3Just Joined!
- Join Date
- Dec 2007
- Location
- bangalore
- Posts
- 38
i m searching for a list of files of the same name in a directory.......eg:XA12C_01,XA12C_02,XA12C_03,XA12 C_04, XB12C_01,XB12C_02,XB12C_03,XC12C_01.............th ats y i m grepping grep $name$suffix* for the similar files and taking their count and incrementing it to make a new file...eg: if number of files for XA12C is 4 then the new file created will b XA12C_05
- 12-08-2007 #4Linux Engineer
- Join Date
- Feb 2005
- Posts
- 1,044
Okay, but you do realise that the * in a regular expression matches zero or more occurrences of the preceding character, so if your $suffix holds an underscore, and $name holds "XA12C", then you'll actually be matching all names with XA12C anywhere in them (beginning, middle or end).
Also be aware that the shell will try to use that * before it passes the argument to grep, so if you've got any filenames that begin with "XA12C" in the directory you're running the command from then grep will see that list of names, and not the pattern - it'll take the first name as the pattern and the rest of the list as the files to search, disregarding stdin completely!


Reply With Quote
