MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

Revision 14 as of 2014-08-06 10:09:04
  • ShellScript

Filter unique values from third column, separated by space

cat datax.log |  awk -F ' ' '/IMEI/{print $3}' | sort | uniq | wc -l

Filter unique values from third column, separated by :

cat datax.log |  awk -F ':' '/IMEI/{print $3}' | sort | uniq | wc -l

Search for text in files recursively

cd startFolder
grep -H "textToSearch" * -R

Copy files to other destination (Win32)

@echo off
REM Mount drive
echo Mounting remote drive
net use z: \\192.168.1.1\backs password /USER:userx

REM copy current day files
echo Copying current day files
forfiles -p "I:" -s -m *FULL*.sqb -d +0 -c "cmd /c copy @path Z:\BACKUPS\@file"

echo Deleting files older than 7 days
REM delete files older than 7 days
forfiles -p "Z:\BACKUPS" -m *.sqb -d 7 -c "cmd /c del @path"

Gzip files that where last modified in 30 or more days (Win32)

forfiles /p "c:\logs" /d -30 /m *.log /c "cmd /c gzip @path "

Run task every day at 01:00 (Win32)

at 01:00 /every:M,T,W,Th,F,S,Su c:\task.bat

Block responses to pings

   1 #block responses to pings
   2 iptables -A INPUT -p icmp -m icmp --icmp-type echo-request -j DROP
   3 iptables -L
   4 #restore responses to pings
   5 iptables -F
   6 iptables -L

Zip SVN modified Java files

# chmod 755 /usr/local/bin/modifiedJavaSvn.sh # on CygWin
svn status | awk '/.java/{ print( gensub( /\\/,"/","g",$2) ); }' | xargs -i zip modifiedJavaFiles.zip {}
unzip -v modifiedJavaFiles.zip

Deploy EAR script

# deploy EAR in remote JBoss . 
# Must have pub SSH keys (authorized_keys) deployed on remote server
# Can be used with cygwin
FILEX=sample.ear
DEST_DIR=/opt/jboss/server/default/deploy/
ECLIPSE_PROJECT=/home/userx/workspace/sample-ear/

deploy()
{
  SERVER=$1
  USER=$2
  echo "Deploying in $SERVER ..."

  cd $PROJECT
  scp target/$FILEX $USER@$SERVER:/tmp
  ssh $USER@$SERVER -C "mv /tmp/$FILEX $DEST_DIR/$FILEX"
  ssh $USER@$SERVER -C "ls -lah $DEST_DIR"
  ssh $USER@$SERVER -C "chmod 666  $DEST_DIR/$FILEX"
  ssh $USER@$SERVER -C "/sbin/service jboss abort"
  ssh $USER@$SERVER -C "sudo /sbin/service jboss start"
}

deploy "example-server" "userx"

List JAR contents to file

  • cd ~/.m2/repository
  • find . -name "*.jar" | xargs -i jar -tf {} > /tmp/explodedJars.txt

  • find . -name "*.jar" | xargs -i sh -c "echo {} ; jar -tf {}" > /tmp/explodedJars.txt

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01