Wednesday, August 24, 2011

In-Place replacement from command line

To replace all occurences of the word "hello" with the word "harrow" in files in the current directory, use perl's in-place substitusion from the command line as follows:

perl -pi -e 's/hello/harrow/g' *.txt

note, the 'g' at the end makes it match [greedily|globally] - ie it will to multiple matches in a single line. You can add an 'i' for case insensitivity.

Full regular expressions can be used, and the *.txt can of course be *.html, *.anything, or just *

SOURCE: http://www.spiration.co.uk/post/522/in-place-replacement-from-command-line

Friday, May 21, 2010

sort & uniq command

sort command is used to sort a file in alphabetical or numberical order.



uniq command is used to extract unique lines from a file.


Thursday, May 13, 2010

Grep command to compare two files

$ cat > a
aap
noot
mies
teun

$ cat > b
noot
vuur
kees
mies

$ grep -v -f b a
aap
teun

$ grep -v -f a b
vuur
kees

Source: http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1113632

Monday, March 1, 2010

Grep commands

Grep recursively into a directory
grep -r "string" ./

Grep ignore case and recursive
grep -ir "string" ./

Grep ignore case, recursive and specific file type
grep -ir --include=*.vhd "string" ./

Grep ignore case, recursive, specific file type and list only matching file name
grep -ir -l --include=*.vhd "string" ./

Grep ignore case, recursive, specific file type, list only matching file name and only whole word matching
grep -ir -l -w --include=*.vhd "string" ./

Sunday, December 13, 2009

Address range decode using CASE statement in VHDL

-- Type decleration
SUBTYPE sram_dev_addr IS INTEGER RANGE 16#100000# TO 16#13FFFF#;
SUBTYPE ctrl_reg_addr IS INTEGER RANGE 16#1FC000# TO 16#1FFFFF#;

-- Address decoding process
proc_access_decode : PROCESS (clk_80m)
VARIABLE own_addr_var : INTEGER RANGE 0 TO 16#1FFFFF#;
VARIABLE dev_sel : STD_LOGIC_VECTOR (1 DOWNTO 0) := "00";

BEGIN
-- type convert the input proc_addr
own_addr_var := conv_integer (UNSIGNED (proc_addr)) ;
CASE own_addr_var IS
WHEN sram_dev_addr => dev_sel := "01";
WHEN ctrl_reg_addr => dev_sel := "10";
WHEN OTHERS => dev_sel := "11";
END CASE;
END PROCESS proc_access_decode;

Wednesday, December 9, 2009

Delete unwanted whitespaces

VIM Command to delete unwanted whitespaces at the end of line in a file.

:%s/\s*$//

Tuesday, December 8, 2009

RANGE DECLERATION IN VHDL

Range cannot be declared for STD_LOGIC_VECTOR types.


CONSTANT ARINC1_ADDR_RNG_L : STD_LOGIC_VECTOR (22 DOWNTO 2) := '1' & X"F0000" ;
CONSTANT ARINC1_ADDR_RNG_H : STD_LOGIC_VECTOR (22 DOWNTO 2) := '1' & X"F1FFF" ;

TYPE ARINC1_ADDR_RNG IS RANGE ARINC1_ADDR_RNG_L TO ARINC1_ADDR_RNG_H ;

Hint: Range must be a scalar type.