Recent Notes
Displaying keyword search results 1 - 10
Created by timo on January 25, 2012 20:13:13
Last update: January 25, 2012 20:13:13
The MIPS CPU is able to run both big-endian and little-endian. So a system built on MIPS can be either big-endian (mips) or little-endian (mipsel).
The file command shows the architecture:
$ file ls
ls: ELF 32-bit LSB executable, MIPS, ...
but readelf will tell the endianness:
$ readelf -h ls
ELF Header:
Magic: 7f 45...
Created by voodoo on November 22, 2011 12:27:12
Last update: November 22, 2011 12:31:50
Unix hidden files are named starting with a dot ".".
To find hidden files in the current directory:
$ find . -type f -name '.*'
or
$ find . -type f | grep \\/\\.
To find hidden files in the marketing directory:
$ find marketing -type f -name '.*'
or
$ find marketing -type f | grep \\/\\.
Created by magnum on June 20, 2011 20:52:22
Last update: June 21, 2011 08:44:01
Several ways to remove empty lines from a file with Unix utilities:
Remove all empty lines with grep :
cat test.txt | grep -v '^\s*$'
or
grep -v '^\s*$' test.txt
Remove all empty lines with sed :
sed '/^\s*$/d' test.txt
Remove empty lines at the beginning of file with sed :
sed '0,/\w/p' leadingBlankLines.txt | sed '0,/\w/d...
Created by voodoo on June 21, 2011 08:32:15
Last update: June 21, 2011 08:32:15
The Dos2unix package includes utilities "dos2unix" and "unix2dos" to convert plain text files in DOS or MAC format to UNIX format and vice versa.
By default, it replaces the original file:
$ dos2unix base64_encoded.txt
dos2unix: conver...
Use the -n switch to write the converted output to a new file:
$ dos2unix -n base64_encoded.txt unix_formatted.tx...
Using STDOUT ( - ) as output file does not work :
$ dos2unix -n base64_encoded.txt -
Use input redirection to write to STDOUT:
$ dos2unix < base64_encoded.txt
Created by Dr. Xi on June 20, 2011 15:18:06
Last update: June 20, 2011 15:18:06
Perl does not have built-in functions to get the base name or dir name from a file path. But on the Unix platforms we can rely on the executables basename and dirname .
#!/usr/bin/perl
$f = '/A path with/space "/file...
The quotes, escapes, and chomp are necessary:
# This fails when there's a space in $f
$base =...
Created by woolf on May 20, 2011 14:00:35
Last update: May 20, 2011 14:01:36
To remove new line characters from a file:
with tr :
tr -d '\n' < the-file.txt or
cat the-file.txt | tr -d '\n'
with sed :
sed ':a;N;$!ba;s/\n//g' the-file.txt or
cat the-file.txt | sed ':a;N;$!ba;s/\n//g'
The sed version is a bunch of commands to manipulate the register etc. Regex replace " s/\n//g " does not work because sed regex works on a single line.
More tips from this Linux blog: http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/
Created by woolf on April 12, 2011 09:20:08
Last update: April 12, 2011 09:20:08
First try (this lists files by directory, including directories themselves):
ls -R -lrt
Second try:
find . -type f | xargs ls -lrt
Created by Fang on March 30, 2011 15:31:24
Last update: March 30, 2011 15:31:24
You get this error when you are trying to compile with JDK 1.5 (class version 49), but your dependency was compiled by JDK 1.6 (class version 50). Check the JAVA_HOME setting, and make sure it's pointing to JDK 1.6. On Unix, use
set | grep -i java_home
On Windows, just
set JAVA_HOME
Created by Dr. Xi on March 28, 2011 11:11:33
Last update: March 28, 2011 11:13:21
grep is a versatile command with many variations (grep, egrep, fgrep, then various implementations). It uses a regula expression (regex) pattern to filter input. But then there are basic and extended flavors of regex - leading to even more confusion. And, beware that there are lots of bad examples of regex in the wild... There are two critical questions to ask when you use grep: which grep implementation are you using? what is the flavor of the regex? Here are some examples for gnu grep v2.7:
# Find all numbers (no decimal point), basic regex... Use the -o flag to show only the matching part instead of the whole matching line: grep -o -E '\b[0-9]{2}\b' The good thing about the gnu grep is that it...
Created by Dr. Xi on February 17, 2011 12:59:47
Last update: February 17, 2011 12:59:47
Operator Meaning -e file1 file1 exists -b file1 file1 is a block special file -c file1 file1 is a character special file -d file1 file1 is a directory -f file1 file1 is a regular -g file1 Set Group ID (sgid) bit is set for file1 -h file1 file1 is a symbolic link -k file1 Sticky bit is set for file1 -L file1 file1 is a symbolic link -p file1 file1 is a named pipe (FIFO) -r file1 file1 is readable by the current process -s file1 file1 has a size greater than zero. -t FileDescriptor FileDescriptor is open and associated with a terminal. -u file1 Set User ID (suid) bit is set for file1 -w file1 Write flag (w) is on for file1 -x file1...