Skip to content

Commit

Permalink
Removed all "cat | grep", with grep, awk and sed.
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Amadori <marco.amadori@gmail.com>
  • Loading branch information
mammadori committed Oct 11, 2008
1 parent 8c74393 commit 70366e3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/live-snapshot
Expand Up @@ -346,8 +346,8 @@ Do_filelist ()
TMP_FILELIST=$1
if [ -f "${SNAP_LIST}" ]
then
# Generate include list
for entry in $(cat "${SNAP_LIST}" | grep -v '^#.*$' | grep -v '^ *$')
# Generate include list removing empty and commented lines
for entry in $(sed -e '/^ *$/d' -e '/^#.*$/d' "${SNAP_LIST}")
do
if [ -d "${entry}" ]
then
Expand Down
10 changes: 5 additions & 5 deletions scripts/live
Expand Up @@ -613,7 +613,7 @@ copy_live_to ()
if [ "${copytodev}" = "ram" ]
then
# copying to ram:
freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ) )
freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo ) )
mount_options="-o size=${size}k"
free_string="memory"
fstype="tmpfs"
Expand Down Expand Up @@ -846,10 +846,10 @@ do_snap_copy ()
# look for free mem
if [ -n "${HOMEMOUNTED}" -a "${snap_type}" = "HOME" ]
then
todev=$(cat /proc/mounts | grep -s " $(base_path ${todir}) " | awk '{print $1}' )
freespace=$(df -k | grep -s ${todev} | awk '{print $4}')
todev=$(awk -v pat="$(base_path ${todir})" '$2 == pat { print $1 }' /proc/mounts)
freespace=$(df -k | awk '/'${todev}'/{print $4}')
else
freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( awk '/\<Cached/{print $2}' /proc/meminfo))
fi

tomount="/mnt/tmpsnap"
Expand Down Expand Up @@ -963,7 +963,7 @@ try_snap ()
# strange things happens, user confused?
snaploop=$( losetup ${dev} | awk '{print $3}' | tr -d '()' )
snapfile=$(basename ${snaploop})
snapdev=$(cat /proc/mounts | awk '{print $2,$1}' | grep -es "^$( dirname ${snaploop} )" | cut -f2 -d ' ')
snapdev=$(awk -v pat="$( dirname ${snaploop})" '$2 == pat { print $1 }' /proc/mounts)
else
snapdev="${dev}"
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/live-bottom/08persistence_excludes
Expand Up @@ -35,7 +35,7 @@ fi

# live-initramfs script

dirs="$(cat /root/etc/live-persistence.binds | grep -v '^#.*$' | grep -v '^ *$' | tr '\n' '\0')"
dirs="$(sed -e '/^ *$/d' -e '/^#.*$/d' /root/etc/live-persistence.binds | tr '\n' '\0')"
if [ -z "${dirs}" ]
then
exit 0
Expand Down
2 changes: 1 addition & 1 deletion scripts/live-functions
Expand Up @@ -21,7 +21,7 @@ really_export ()
STRING="${1}"
VALUE="$(eval echo -n \${$STRING})"

if [ -f /live.vars ] && cat /live.vars | grep -sq "export ${STRING}"
if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars
then
sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
else
Expand Down

0 comments on commit 70366e3

Please sign in to comment.