Вы propably currupted файловая система от карты флэш-памяти. Я недавно имел подобный эффект с картой с интерфейсом USB - после отмены продолжающейся операции копии, это отметило палку usb как полную - хотя ничто не было записано.
Таким образом, propably целая файловая система должна дать Вам пространство снова.
Я изменил бы несколько вещей о.
find_code() {
# assign all arguments (not just the first ${1}) to MATCH
# so find_code can be used with multiple arguments:
# find_code errorCode
# find_code = 1111
# find_code errorCode = 1111
MATCH="$@"
# For each file that has a match in it (note I use `-l` to get just the file name
# that matches, and not the display of the matching part) I.e we get an output of:
#
# srcdir/matching_file.c
# NOT:
# srcdir/matching_file.c: errorCode = 1111
#
grep -lr "$MATCH" ${SRCDIR} | while read file
do
# echo the filename
echo ${file}
# and grep the match in that file (this time using `-h` to suppress the
# display of the filename that actually matched, and `-n` to display the
# line numbers)
grep -nh -A5 -B5 "$MATCH" "${file}"
done
}
Вы можете использовать find
с двумя -exec
s, второй будет выполнен, только если первый будет успешным, например поиск только в файлах .cpp
, .c
и .cs
:
find_code() {
find ${SRCDIR} -type f \
\( -name \*.cpp -o -name \*.c -o -name \*.cs \) \
-exec grep -l "= ${1}" {} \; -exec grep -n -C5 "= ${1}" {} \;
}
, поэтому первый grep
печатает имена файлов, содержащие ваш pattern, а второй напечатает совпадающие строки + контекст, пронумерованные, из соответствующих файлов.
MATCH="= ${1}"
. Я также добавил--include=*.c --include=*.cpp --include=*.java --include=*.cs
ограничить поиск исходными файлами.Спасибо! – TravisThomas 10.08.2013, 00:53