Creating a new repository for SVN
svnadmin create /path/to/svn/newrepository
Importing
svn --username user import http://svnsite.com/path/to/svn/newrepository -m "initial import"
#note about importing
#create a local folder called newrepository and put whatever code you want to import into newrepository
#run svn from newrepository
Permission denied when importing
# Do this on the server's svn directory
sudo chown -R www-data:www-data svn
Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts
Saturday, June 6, 2009
Wednesday, June 3, 2009
Adding an extension to a bunch of files
#I made a bunch of text files for Windows, but XP cannot open them without an extension
#This was a quick fix
find . -type f -exec mv {} {}.txt \;
#This was a quick fix
find . -type f -exec mv {} {}.txt \;
Monday, June 1, 2009
Inserting a blank line with sed
#I found this to be a bit tricky
sed -e '/pattern/i\
\ # <-- this is the key
' input_file > output_file
sed -e '/pattern/i\
\ # <-- this is the key
' input_file > output_file
Saturday, May 30, 2009
awk example using arrays, the split() function, and regex
#record format
Request: 10
As Of: 05/27/2009 1:34:58 pm
Irrevelant Data ...
Summary: Virus on PC.
Description: Virus on PC.
Request: 11
As Of: 05/27/2009 1:34:58 pm
Irrevelant Data...
Summary: room1 several computers in a row are freezing up and student...
Description: room1 several computers in a row are freezing up and students have to reboot.
awk -v pat1="room1" -v pat2="freezing|crash" 'BEGIN { RS=""; FS="Summary"; i=0; j=0; k=0 } {\
i=i+1; \
field1=$1; \
split(field1,sub_fields,":"); \
request=sub_fields[1]; \
the_date=sub_fields[4]; \
if ($2 ~ pat1){ \
k=k+1; \
if ($2 ~ pat2){ \
j=1+j; \
print "***Record***", request, the_date; print " ---Start Data---", $2; } } \
} END { print "Processed, ", i, ",num of lab matches,", k,", records num of keywords matches: ,", j }' requests
#Output
***Record*** Request 05/27/2009 1
---Start Data--- : room1 several computers in a row are freezing up and student...
Description: room1 several computers in a row are freezing up and students have to reboot.
Processed, 2 ,num of lab matches, 1 , records num of keywords matches: , 1
Request: 10
As Of: 05/27/2009 1:34:58 pm
Irrevelant Data ...
Summary: Virus on PC.
Description: Virus on PC.
Request: 11
As Of: 05/27/2009 1:34:58 pm
Irrevelant Data...
Summary: room1 several computers in a row are freezing up and student...
Description: room1 several computers in a row are freezing up and students have to reboot.
awk -v pat1="room1" -v pat2="freezing|crash" 'BEGIN { RS=""; FS="Summary"; i=0; j=0; k=0 } {\
i=i+1; \
field1=$1; \
split(field1,sub_fields,":"); \
request=sub_fields[1]; \
the_date=sub_fields[4]; \
if ($2 ~ pat1){ \
k=k+1; \
if ($2 ~ pat2){ \
j=1+j; \
print "***Record***", request, the_date; print " ---Start Data---", $2; } } \
} END { print "Processed, ", i, ",num of lab matches,", k,", records num of keywords matches: ,", j }' requests
#Output
***Record*** Request 05/27/2009 1
---Start Data--- : room1 several computers in a row are freezing up and student...
Description: room1 several computers in a row are freezing up and students have to reboot.
Processed, 2 ,num of lab matches, 1 , records num of keywords matches: , 1
Friday, May 29, 2009
Removing carriage returns with sed
sed -e s/$'\r'/\ /g input_file # remove carriage returns
sed -e 's/\n/ /g' input_file # remove newlines
sed -e 's/\n/ /g' input_file # remove newlines
Insert text before a pattern with sed
cat some_file | sed '/pattern/i\
text to insert
' > output_file
text to insert
' > output_file
Remove empty lines with vi
In ex mode:
:1,$s/^$//
Sometimes you need to do this too:
:1,$s/^\n//
May be able to do this:
:1,$s/^[\n$]//
:1,$s/^$//
Sometimes you need to do this too:
:1,$s/^\n//
May be able to do this:
:1,$s/^[\n$]//
Show special characters in vi
:set list
# see control chars (tabstops, control characters, etc)
# see control chars (tabstops, control characters, etc)
Example of processing multiline records with awk
Processing multiline records is tricky. It is easier to use blank lines as record separators.
#example records
ink1 4.99
red
ink2 5.99
yellow
awk ' BEGIN { RS=""; FS=" "} { r1=$1; r2=$2; r3=$3; print "***Record***" r1 " " r2 " " r3 }' inks
#What it prints out
***Record***ink1 4.99
red
***Record***ink2 5.99
yellow
#example records
ink1 4.99
red
ink2 5.99
yellow
awk ' BEGIN { RS=""; FS=" "} { r1=$1; r2=$2; r3=$3; print "***Record***" r1 " " r2 " " r3 }' inks
#What it prints out
***Record***ink1 4.99
red
***Record***ink2 5.99
yellow
Thursday, May 28, 2009
Showing a decimal expansion with bc
#3 digits after the decimal place
echo "scale=3; 41.0 / 939.0" | bc
echo "scale=3; 41.0 / 939.0" | bc
Wednesday, May 27, 2009
awk script to generate count of each program
#csv of format:
#the_program, any_data, any_data, ....
#
#this script counts number of repetitions of a program
cat program-list.csv | awk -F',' '/[a-zA-Z0-9]+/{print $1}' | sort | uniq -c
#the_program, any_data, any_data, ....
#
#this script counts number of repetitions of a program
cat program-list.csv | awk -F',' '/[a-zA-Z0-9]+/{print $1}' | sort | uniq -c
Subscribe to:
Posts (Atom)