Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
r *xyz* ==> list all file id the directory where the name of ls -ltr wc -l ==> l
ist all files and wc -l is used to lsit count of the files ls -ltr > my_file.txt
==> output of th e list comand is directed to my_file.txt ls -ltr >> my_file.tx
t ==> outp ut of the list comand is appended to my_file.txt ls -ltr grep "13 Dec
" ==> sele ct all file where file date is dec 13 ls -ltr grep "Dec 13" ==> sele
ct all file where file date is dec 13 ls -ltr grep "1[29] Nov" ==> grep all file
s where date st arts with 1 and 2'nd charter is 2 or 9, so list all files ==> th
at have a dates of Nov 12 or Nov 19 ls -ltr grep -E "Nov (12 26 09)" ==> grep -E
, gr ep using extended expression. will list all files where date are ==> Nov 1
2 or 26 or 09 ls -allp ==> disp aly / after directory names ls -all grep mdmtm_e
ng grep 2011-03-04 ==> display all file tha t have mdmtm_eng and also have 201103-04 as part of the file name ls -ltr grep ctl wc -l ls -all grep -i <<file nam
e>> ==> grep -i beomes case incensit ive ls grep mdmtm_engyaustbatch grep 2011-1
1-10 grep zip xargs zgrep -l Level2 SettlementReconciliation wc -l ==>> count th
e number of zip files where thier date is 2011-11-10 and contai ns the string (S
ettlementLoader-loaders) ls -lrt ==>sorts by ascending creation t imestamp order
(-l =long (detailed) display ) ls -lt ==>sorts by descending creation timestamp
ram used to display the amount of available disk space for filesystems on which
the invoking user has appropriate read access. du -sm * ==> show the list of fi
le in MB sorted by size
du -sk * ==> shows the file usage for every file and directory beneath the curre
nt, or specified, directory. du -g ==> shows the subfolder size in megabyte s du
-sm <foldername> du /EAI sort -n ==> list all folder under /EAI sorted size fin
d . -size +50000
________________________________________________________________________________
____________________________________
ps -ef grep MIBBGeneric -v grep ==>> show the proces-id for MIBBGeneric -v g rep
to exclude the grep command from appreaing in the list
_______________________________________________________________ find -name 'mypa
ge.htm' In the above command the system would search for any file named mypage.h
tm in th e current directory and any subdirectory. find . -name 'heapdump*' -exe
c echo rm '{}' \; find . -name 'heapdump*' -exec ls -l '{}' \;
___________________________________________________________________ cat MIRNLIST
ING_ENVESTRA_20101202.csv wc l
to find the number of records in the csv file __________________________________
_________________________________ chmod options filename --- lets you change the
read, write, and execute permissi ons on your files. The default is that only y
ou can look at them and change them, but you may somet imes want to change these
permissions. For example, chmod o+r filename will make the file readable for ev
eryone, and ch mod o-r filename will make it unreadable for others again. Permis
sions, another way You can also change file permissions with letters: u = user (
yourself) g = group a = everyone r = read w = write x = execute chmod u+rw {file
spec} Give yourself read and write permission chmod u+x {filespec} Give yourself
execute permission. chmod a+rw {filespec} Give read and write permission to eve
ryone.
________________________________________________________________________________
______________________________________ gzip -9 <name of file> will compress <fi
lename> and remove the original file Unzip -p // will unzip the ziped file and b
rowse the file inside unzip -v // will give u the actual ziped file name inside
the zip file unzip -l // will give u the actual ziped file name inside the zip f
ile (same as -v) bzip2 -9vv CSD_20111014.csv (compressor only, used for zipping
one file only) a nd takes longer to zip but more disk space effecient
tar eg:
// used for archiving only and no compression tar -cvf - * bzip2 -9c > CSD_20111
014_ByFRMP.tar.bz2 --> * stands for every non hidden files within the current fo
lder --> tar all files and send the output into bzip2 utility to co mpress the t
ar fil and then save the output to << file_name.tar.bz2>>
******************zip a lot of file in a folder into one filename **************
********************************** zip -9r archname.zip . compress all files in
the current directory (not to b e used with fileglob pattern such as *.log or *
.dat, because the fileglob might expand so much ls grep log xargs zip -9r arachi
vename.zip // zip all files that hav e "log" in the file name, works if the file
names dose not have spaces. ls grep log xargs zip -9r log_file_21112011.zip //e
xample *************************************************************************
******* *********************************** in case we have file names in the fo
lder that contaiins spaces within the file n ame, then we can use the following:
ls grep log while read line do zip -9r backup_12121961.zip "$line" file name th
at have the space done
"$line" will be substituted with the
// dont forget to remove the original log files that was compressed ************
******************************************************************** ***********
********************** to uncompress bz2 file = bzip2 -d __file_name__ tands for
decompress. without retaining original bziped2 file. to uncompress bz2 file = b
zip2 -dc __file_name__ > new File Name decompress and retain the original file t
o uncompress tar.bz2 file = bzip2 -dc __file_name__ ncompress the bz2 .tar file
tar -xvf --> -d s --> -dc --> to u
it is better to do the bzip2 and tar operation into a temp folder. _____________
___________________________________________________________________ ____________
_____________________________________________________ FTP commands ascii ==>to s
et the mode of file transfer to ASCII (this is the default and transmits seven b
its per character) binary ==> to set the mode of file transfer to binary (the bi
nary mode transmits all eight bits per byte and thus provides less chance of a t
ransmission error and must be used to transmit files other tha n ASCII files)
bye ==> to exit the FTP environment (same as quit) close ==> to exit the FTP env
ironment (same as quit) pwd cd lcd ==> to print current working directory ==> to
change directory on the remote machine ==> to cgange the current directory on t
he local machine
get ==>to copy one file from the remote machine to the local machine . If you ar
e going to copy a z.ip file from remote place or send a zip file or any binary f
iles, you have to be in binary session. just type bin and enter to eneter a bina
ry session get ABC DEF copies file ABC in the current remote directory to (or on
top of) a file named DEF in your current local directory. get ABC copies file A
BC in the current remote directory to (or on top of) a file with the same name,
ABC, in your current local directory. mget ==>to copy multiple files from the re
mote machine to the local machine; you are prompted for a y/n answer before tran
sferring each file mget * copies all the files in the current remote directory t
o your cu rrent local directory, using the same filenames. Notice the use of the
wild card character, *. example: ftp> mget *.html mput ==>to copy multiple file
s from the local machine to the remote machine; you are prompted for a y/n answe
r before transferring each file example ftp> mput *.html open ==>to open a conne
ction with another computer open brubeck opens a new FTP connection with brubeck
; you must enter a username and password for a brubeck account (unless it is to
be an anonymous connection). put ==> to copy one file from the local machine to
the remote machine help ==> Type help or ? to view list of all available ftp com
mands ? ==> Type help or ? to view list of all available ftp commands __________
_____________________________ Vi Commands :w =====> To save the current file :q
=====> to quit :wq =====> to save and quit / =====> Go to command line /[a-zAZ]+
=====> search the file for any smallor large alpha caracter followed by + eg: D
+Z x i dd yy =====> esc then x to delete a characer =====> esc then i to enter i
nto insert mode =====> delete one line =====> copy whole line
shift+p =====> to paste above cursor p =====> to paste below cursor shift+c ====
=> to overwrite rest of line starting from the cursor position w ith what ever i
n buffer
___________________ 3. Day - Day of the month (1-31) ________________ 4. Month Month of the year (1-12) ______________5. Weekday - Day of the week. (0-6, whe
re 0 indicates Sunday) 30 0,12 * * * /some/script/or/command
So, when we combine all the schedule elements, we know when and how often this t
ask will run. Going on the above example, this task would run: At 30 minutes pa
st the hours of 0 (midnight) and 12 (noon), EVERY day of the mon th, EVERY month
of the year and EVERY day of the week. In other words, the above task would run
every single day at 12:30AM and 12:30PM - A comma is used to input multiple val
ues for a field. For example, if you want ed a task to run at hours 12, 15 and 1
8, you would enter that as "12,15,18". - A line in crontab file like below remov
es the tmp files from /home/someuser/tm p each day at 6:30 PM. 30 18 * * * rm /h
ome/someuser/tmp/*
welcome to crontabrocks.org Crontabrocks.org is a quick and simple guide to cron
tab usage. The cron daemon p rovides the ability for a system administrator or a
ny other user (if permitted t o do so) to automate the routine running of script
s, tasks or any other server f unction on a regular basis. The cron daemon is so
mewhat similar to what the "sch eduled tasks" tool on a Windows machine would be
. Most Unix/Linux based systems come with the cron daemon installed and configur
ed to start on server boot by de fault. There is usually not much work, if any,
that you have to do to start usin g the cron daemon. The server itself usually c
omes out of the box with several s ystemic cron jobs already set up, so adding y
our own jobs to the schedule is not big deal. Cron jobs are scheduled by a user
using a tool known as "crontab". Th e crontab is nothing more than a text file w
ritten in a syntax that the cron dae mon understands. So first, let's talk about
how to handle the crontab itself...
Accessing the Crontab crontab -e - opens the user's crontab file for viewing/edi
ting crontab -l - simply lists the crontab file's contents for the user. Think o
f it as a "cat" function for the crontab. The following commands would apply to
the user which you are logged in as. For e xample, if you are logged in as "root
", these commands would pertain to root's c rontab file. crontab -e - opens the
user's crontab file for viewing/editing crontab -l - simply lists the crontab fi
le's contents for the user. Think of it as a "cat" function for the crontab.
crontab -r - removes the crontab file contents for the user But what if you want
to edit another user's crontab? The system administrator is usually logged in a
s "root", but making changes to a nother user's crontab file or simply looking a
t another user's crontab file is o ften necessary. For situations like this, you
can append the "-u" flag followed by the desired username. For example, if logg
ed in as root but you want to edit the crontab for the user "admin", you would d
o the following: crontab -e -u admin The same logic applies to the other crontab
commands as well, such as: crontab -l -u admin - lists the crontab entry for th
e "admin" user. crontab -r -u admin - removes the crontab entry for the "admin"
user.
Writing to the Crontab Now that you know how to access the crontab, let's take a
look at the syntax of the crontab entry itself. A typical crontab entry might l
ook like this: 30 0,12 * * * /usr/local/scripts/whatever.script OK, so what does
that mean? Well, there are 2 parts to the entry you see above. In fact, any cro
ntab entry has 2 parts: Part 1 - The schedule The schedule, which governs when t
he task will run, consists of a string of numb ers, possible commas and asterisk
s (*). So, in the above example, the schedule is: 30 0,12 * * * What you are see
ing is actually split up into 5 sections. The following chart il lustrates what
each section of the schedule is for: 1. 2. 3. 4. 5. Minute - Minutes after the h
our (0-59). Hour - 24-hour format (0-23). Day - Day of the month (1-31). Month Month of the year (1-12). Weekday - Day of the week. (0-6, where 0 indicates Su
nday).
* = An asterisk in a schedule field indicates "every". It means that the task wi
ll occur on "every" instance of the given field. So a "*" on the Month field in
d icates the the task will run "every" month of the year. A * in the Minutes fie
ld would indicate that the task would run "every" minute. , = A comma is used to
input multiple values for a field. For example, if you wa nted a task to run at
hours 12, 15 and 18, you would enter that as "12,15,18".
Let's take a look at how this format fits into the syntax of a crontab entry: __
_______________________ 1. Minute - Minutes after the hour (0-59) ______________
________ 2. Hour - 24-hour format (0-23). ___________________ 3. Day - Day of th
e month (1-31) ________________ 4. Month - Month of the year (1-12) ____________
__5. Weekday - Day of the week. (0-6, whe re 0 indicates Sunday) 30 0,12 * * * /
some/script/or/command
So, when we combine all the schedule elements, we know when and how often this t
ask will run. Going on the above example, this task would run: At 30 minutes pa
st the hours of 0 (midnight) and 12 (noon), EVERY day of the mon th, EVERY month
of the year and EVERY day of the week. In other words, the above task would run
every single day at 12:30AM and 12:30PM . Let's play around with the schedule a
little bit and try something different. Wh at if we had something like this: 15
,45 0,12,6 20 1,2,3 0 /some/script/or/command Wow! Now this is a pretty complex
crontab entry. Let's decipher it... 15,45 - This means that the task will run at
15 and 45 minutes past the hour. Bu t what hours and what days? Well, that's co
ming up. 0.12.6 - The task will run during the hours of 0 (midnight), 12 (noon)
and 6AM. 20 - The task will run on the 20th day of the month. But during what mo
nths? 1,2,3 - The task will run only during tibco.clientVar.FileTransfer/CBA/Out
bound/CBA_DirectDebit_AlertUserBy=16:05:00 TRA files /EAI/tibco/tra/domain/CMSPR
D/application/CBA
ls -l ~/OUTAGE
http://l4298mq1/apps/EMMA_Viewer_Prototype/index.php ***************************
************************** Get SQlLoader example get XML parsing example with da
ta