面试题总结之Linux/Shell

Linux

Linux cshrc文件作用

Linux如何起进程/查看进程/杀进程

Linux 文件755 代表什么权限

Linux辅助线程

Linux进程间通信方法

  pipeline,msgq...

  进程间通信_百度百科

    http://baike.baidu.com/link?url=tLNXNQvG5Wo6NptnjkflYaUQbdqW5fC3n40Cv4iF4YSX5EzgfJgwIbZnAfpXLVV1QRvP1293Dgo9qRBmSVfME_

Shell

What is $*?
  Will display all the commandline arguments that are passed to the script

What is the difference between a shell variable that is exported and the one that is not exported?
  export LANG=C
  will make the variable LANG the global variable, put it into the global environment. all other processes can use it.
  LANG=C
  will change the value only in the current script.

How will you list only the empty lines in a file (using grep)?
  grep "^[ ]*$" filename.txt
  In character set (between [ and ] one space and tab is given)
  this command will gives all the blank line including those having space and tabs (if pressed)only

How do you read arguments in a shell program - $1, $2 ?
  #!/bin/sh
  for i in $*
  do
  echo $i
  done
  On executig the above script with any number of command-line arguments it will display all the parametsrs.

How would you get the character positions 10-20 from a text file?
  cut -c10-20 <filename.txt>
  or
  cat filename.txt | cut -c 10-20

时间: 2024-08-05 12:25:27

面试题总结之Linux/Shell的相关文章

Linux Shell sort 指定排序第几列

ip.txt 里存储着ip信息 统计排序后取前10条 awk '{cnt[$1]++} END{for (ip in cnt) print ip":"cnt[ip]}' ip.txt | sort -k 2 -rn -t":" | head -n 10 awk '{cnt[$1]++} END{for (ip in cnt) print cnt[ip],ip}' ip.txt | sort -rn | head -n 10 sort -k  根据第几列排序  -n

linux shell脚本执行错误:bad substitution

脚本test.sh内容: #!/bin/bash read pressKey indexes=0 c=${pressKey:indexes:1} 使用调试方式执行:sh -x test.sh第3行总出现bad substitution提示信息. 百思不得其解: 于是百度,查到一条有用信息,这与linux shell使用的是/bin/sh,还是/bin/bash有关系.我的脚本中指定使用的是/bin/bash shell,但是我在调试的时候使用的是sh shell,因此调试时导致错误提示信息. 解

linux shell 数组建立及使用技巧

转自linux shell 数组建立及使用技巧 linux shell在编程方面比windows 批处理强大太多,无论是在循环.运算.已经数据类型方面都是不能比较的. 下面是个人在使用时候,对它在数组方面一些操作进行的总结. 1.数组定义 [[email protected] ~]$ a=(1 2 3 4 5)[[email protected] ~]$ echo $a1 一对括号表示是数组,数组元素用“空格”符号分割开. 2.数组读取与赋值 得到长度: [[email protected] ~

Linux shell脚本-基础学习笔记

Linux脚本能力不是太强,最近再补习下,毕竟linux shell在日常工作中还是很普遍的, 用起来更方便.省时省力. 以下是学习笔记,偏理论,后面有几个例子,供参考. shell脚本组成元素系统命令.文本处理工具(grep\sed等).变量.条件判断.循环结构和函数 -------------------------------------------- 三剑客:grep,sed,awk,还有wc,sort,head等 ------------------------------------

Linux Shell脚本攻略(1.10)

1.10 获取.设置日期和延时 很多应用程序需要以不同的格式打印日期.设置日期和时间.根据日期和时间执行某项操作.延时通常用于在程序执行过程中提供一段等待时间(比如1秒).同样的,我们也能够一多种格式打印日期,或者在命令行中设置日期.在类Unix系统中,日期被存储为一个整数,其大小为自世界标准时间起所流逝的秒数.这种计时方式称为纪元时或Unix时间. 1.10.1 获取.设置时间 以下的程序给出了多种用法: #!/bin/bash start=$(date +%s) #获取纪元时间 date #

Linux Shell脚本攻略(1.8)

1.8 使用别名 linux中的别名就相当于windows中的快捷方式,使用别名可以省去用户输入一长串命令序列的麻烦. 1.8.1 创建临时别名(快捷方式) alias new_command='command sequence' #格式说明 alias install='sudo apt-get install' #实例说明 在声明 install='sudo apt-get install'之后,就可以用install代替'sudo apt-get install'了.使用这种方式声明的别名

Linux shell脚本基础学习详细介绍(完整版)一

Linux shell脚本基础学习这里我们先来第一讲,介绍shell的语法基础,开头.注释.变量和 环境变量,向大家做一个基础的介绍,虽然不涉及具体东西,但是打好基础是以后学习轻松地前提.1. Linux 脚本编写基础◆1.1 语法基本介绍 1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编辑好脚本时,如果要执行该脚本,还必须使其可执行. 要使脚本可执

Linux shell脚本基础学习详细介绍(完整版)二

详细介绍Linux shell脚本基础学习(五) Linux shell脚本基础前面我们在介绍Linux shell脚本的控制流程时,还有一部分内容没讲就是有关here document的内容这里继续. Linux shell脚本基础已经被分成好几个部分了,这里对控制流程的内容也就马上讲完了,这是最后一部分关于here document,这里举例稍微有点复杂,我们慢慢来分析这个复杂Linux shell脚本. 6. Here documents 当要将几行文字传递给一个命令时,here docu

“Linux Shell编程”视频学习笔记

一.Linux Shell基础编程 视频1 1.1.查看你系统shell信息 $ cat /etc/shell 命令可以获取Linux系统里面有多少种shell程序 $ echo $SHELL 命令可以查看当前你所使用的shell是哪一个 1.2.查看文件信息,ls $ ls -l 查看文件信息:文件类型.文件权限.文件硬链接数.文件所属用户.文件所属组.文件大小.文件最近修改时间.文件名 1.3.改变文件权限,chmod 只有root用户或者文件的所有者能改变文件的权限 例子:$ chmod