Pacific-Design.com

    
Home Index

1. Bash

+ Concurrency

+ Crontab

+ Date

+ Debug

+ Escape String

+ Large Files

+ Matrix

+ Processes

+ Random URL

+ Read File

+ Social

+ System

+ Tables

+ Tools

+ Tutorials

+ awk

+ sed

+ xargs

+ zLinks

Bash /

Backup Files

a() {

    mkdir -p ~/.archive
    DATE=$(date '+%C%y-%m-%d-%k_%H%M')
    cp $1 ~/.archive/$(basename $1).${DATE}
    #tar czvf ~/.archive/$(basename $1).${DATE}.tar $1
    ls -l ~/.archive/
}

Trim trailing spaces

# trim leading and trailing spaces
sed -i 's/^ *//;s/ *$//' src/main/resources/search-terms.txt

# delete blank lines
sed -i '/^\s*$/d' src/main/resources/search-terms.txt

# remove double quotes  
sed -i 's/\"//g' src/main/resources/search-terms.tx

Escape single quote in awk with \x27


cat delete.sorted | awk '{print "DELETE FROM links WHERE domain=\x27"$1"\x27;"}'

The most common Linux shell is named "Bash". The name comes from "Bourne Again Shell"

  1. CommandlineFu.com
  2. An A-Z Index of the Bash Command Line

#!/bin/bash                                                                                        
#-----------------------------------------#
DATE=$(date '+%C%y-%m-%d-%k')
FILE=`echo "$1" | sed 's/\///g'`
tar czvf ~/.archive/${FILE}-${DATE}.tar $1
#-----------------------------------------#