Morgan Stanley

df|grep run|awk '{print $5}'|sed 's/%//g'

    sed [options] 'command' file(s)

    sed [options] -f scriptfile file(s)
    awk ' pattern {action} '

#!/usr/bin/ksh
#path=/home/edrea/1.txt
#path1=/home/edrea/2.txt
for i in /home/edrea/*.del
do
newfile=`echo $i | sed 's/\.del//g'`
echo $i
echo $newfile
mv $i $newfile
done

Ø The $(...) Construct

   $ file=exec.o

   $ lastchar=$(echo $file | sed 's/.*\(.\)$/\1/')

   $ echo $lastchar

   $ filename=/users/steve/memos

   $ firstchar=$(echo $filename | cut -c1)

   $ filename=$(echo $filename | tr "$firstchar" "^")    #translate / to ^

   $ filename=/users/steve/memos

   $ filename=$(echo $filename | tr "$(echo $filename | cut -c1)" "^")

Ø The expr Command

     expr 1 + 2 #There is one space in 1,+, 2

     expr 10 + 20 / 2

     i=`expr $i + 1`



What is hashing?
What are some differences between linked lists and arrays?
What are the different types of JOINs in SQL?

A few questions on basic command-line syntax in Unix shells:
1. How would you log output and error messages from a command to a file?
2. How would you run the same command on every file in a directory?
3. How would you find the PID of a named process (say if you wanted to kill it)?

1. command >file 2>&1
2. cd dir; for i in *; do command; done
3. ps | grep processname or ps -C processname
#3 I disagree, more like ps aux |awk '$0 ~ /ProcessName/ && $0 !~ /awk/ {print $2}'

recursively renaming .c to .cpp files

列出当前文件夹中所有文件,包括子文件夹里面的:find .  或者 ls -la. 前者会列出子目录的内容.

DBMS questions:

  • Join operations
  • Normalisation with given tables
  • What can be done for making select query more faster ? — expected answer was to use INDEX
  • Some queries were asked with some tables given ..

Table CustomerOrder, columns customerid, orderid, orderdate.
Give a query for customers that placed orders today 
Query to get the day in the last 30 days with the most orders 
What is an index? 
Why not add an index to all the columns? 
What data structure to store index data? 
Why a btree?

* Employees 
o id 
o name 
o department_id 
o start_date 
o salary

* Departments 
o id 
o department

get max salary
get all names and dept
get dept that spends most on salary:

Write a program/script. to find a file in the current directory and sub-directories, tools like find and grep are missing.


amazon-interview-questions1Answer

In a particular directory, list the 15 recently modified files. ls -ltr | tail -15.


Replace a word "Old" with word "new" in all the files of the directory. Solution can be a linux script. also.

sed -i 's/Old/new/g' *.txt

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7899089/viewspace-734824/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7899089/viewspace-734824/

Stanley算法也被称为Stanley-Stembridge算法,主要用于计算可逆写作有限生成排列的生长函数。以下是一个基本的Stanley算法的MATLAB程序示例: ```matlab function sf = stanley(n) % 输入一个正整数n,计算Stanley算法的生长函数 sf = sym(zeros(1,n)); % 创建一个符号变量数组来存储生长函数的值 % 初始化第一个排列(1) p = 1; % 对于每个排列长度m从1到n-1 for m = 1:n-1 % 计算长度为m的排列的生成标志函数 gf = genFlag(p, m); % 计算长度为m的排列的生成多项式 gm = sum(gf); % 更新生长函数数组 sf(m+1) = gm; % 生成下一个长度为m+1的排列 p = nextPerm(p, m); end % 打印生长函数数组 disp(sf); end function gf = genFlag(p, m) % 输入一个排列p和排列的长度m,计算排列的生成标志函数 n = length(p); gf = sym(ones(1,m)); for i = 1:m for j = 1:m if p(i) < p(j) gf(i) = gf(i) * (n - j + 1); end end end end function np = nextPerm(p, m) % 输入一个排列p和排列的长度m,生成下一个长度为m+1的排列 n = length(p); np = [p, m+1]; indexes = 1:n; for i = 1:m indexes(p(i)) = []; end np = [np, indexes]; end ``` 在此程序中,我们首先定义了一个函数`stanley`,其中处理Stanley算法的主要步骤。我们创建一个符号变量数组`sf`来存储生长函数的值,并初始化第一个排列[1]。然后,我们使用一个循环来计算每个长度为m的排列的生成多项式,并将其存储在生长函数数组中。最后,我们输出生长函数数组。 我们还定义了两个辅助函数`genFlag`和`nextPerm`。`genFlag`函数用于计算排列的生成标志函数,`nextPerm`函数用于生成下一个长度为m+1的排列。 请注意,这只是一个基本的Stanley算法程序示例,可能需要根据具体应用进行修改和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值