To perform the redo function using the vi editor use 'Ctrl-R'.
Undo is 'u'.
Wednesday, January 27, 2010
Wednesday, September 16, 2009
Login Activity on a Unix Server
To check the login activity on a Unix server you can run the following command:
# last | head
'head' just displays the last 10 logins.
You can also check the login activity of a specific user:
# last user_name | head
# last | head
'head' just displays the last 10 logins.
You can also check the login activity of a specific user:
# last user_name | head
Total Memory Installed on Solaris
Use the prtconf command to get the total amount of memory installed on a Solaris machine:
# prtconf
# prtconf
Tuesday, September 15, 2009
Counting the number of occurrences of each line in a file
To count the number of occurrences of each line in Linux you can use the following command:
sort input_file | uniq -c > output_file
You may want to ignore the case and then apply the count:
cat input_file | tr '[:upper:]' '[:lower:]' | sort | uniq -c > output_file
sort input_file | uniq -c > output_file
You may want to ignore the case and then apply the count:
cat input_file | tr '[:upper:]' '[:lower:]' | sort | uniq -c > output_file
Monday, September 7, 2009
Removing punctuation from a file in Linux
To remove the punctuation from a file run the following command:
cat input_file | tr -d '[:punct:]' > output_file
cat input_file | tr -d '[:punct:]' > output_file
Converting all Upper Case letters to Lower Case in Linux
To convert all upper case characters to lower case in Linux, run the following command:
cat input_file | tr '[:upper:]' '[:lower:]' > output_file
cat input_file | tr '[:upper:]' '[:lower:]' > output_file
Thursday, August 27, 2009
Obtaining a specific field from a comma separated file (using awk)
If you have a comma separated file e.g.
Name,DateOfBirth,PlaceOfBirth
Jeff,17-09-1982,London
Maggie,08-06-1976,New York
George,14-02-1991,Johannesburg
and you need to extract only the list date of birth from this file you can use the following awk command:
awk 'BEGIN{FS=","}{print $2}' filename > date_of_birth
where FS indicates the file separator (so if your file is delimited with a different character e.g. ":" you would have FS=":" within the awk command) and "$2" indicates the 2nd column.
Name,DateOfBirth,PlaceOfBirth
Jeff,17-09-1982,London
Maggie,08-06-1976,New York
George,14-02-1991,Johannesburg
and you need to extract only the list date of birth from this file you can use the following awk command:
awk 'BEGIN{FS=","}{print $2}' filename > date_of_birth
where FS indicates the file separator (so if your file is delimited with a different character e.g. ":" you would have FS=":" within the awk command) and "$2" indicates the 2nd column.
Subscribe to:
Posts (Atom)