首页 > Linux操作系统 > Linux操作系统 > Morgan Stanley

Morgan Stanley

原创 Linux操作系统 作者:keeking 时间:2012-07-06 15:58:10 0 删除 编辑
df|grep run|awk '{print $5}'|sed 's/%//g'

    sed [options] 'command' file(s)

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

for i in /home/edrea/*.del
newfile=`echo $i | sed 's/\.del//g'`
echo $i
echo $newfile
mv $i $newfile

Ø 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.


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博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

下一篇: 正则表达式Sed
请登录后发表评论 登录


  • 博文量
  • 访问量