ksh

How does extglob work with shell parameter expansion?

放肆的年华 提交于 2019-12-12 17:26:20
问题 I thought I understood the use of the optional ?(pattern-list) in bash (when extglob shell option is on) and by default in ksh. For example in bash : $ shopt -s extglob $ V=35xAB $ echo "${V#?(35|88)x}" "${V#35}" AB xAB But when the matching prefix pattern is just one ?() or one *() , which introduce what I call optional patterns , the 35 is not omitted unless ## is used: $ echo "${V#?(35|88)}" "${V#*(35|88)}" # Why 35 is not left out? 35xA 35xA $ echo "${V##?(35|88)}" "${V##*(35|88)}" # Why

How to autocomplete at the KornShell command line with the vi editor

流过昼夜 提交于 2019-12-12 08:47:33
问题 In the KornShell (ksh) on AIX UNIX Version 5.3 with the editor mode set to vi using: set -o vi What are the key-strokes at the shell command line to autocomplete a file or directory name? 回答1: ESC\ works fine on AIX4.2 at least. One thing I noticed is that it only autocompletes to the unique part of the file name. So if you have the files x.txt, x171go and x171stop, the following will happen: Press keys: Command line is: x x <ESC>\ x 1 x1 <ESC>\ x171 g<ESC>\ x171go 回答2: Extending the other

Difference between korn and bash shell [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-12 08:19:45
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am completely new to Unix. Presently, I have been asked to learn about both KornShell (ksh) and Bash shell . Can some one please give me a short overview about the two? Is the term " shell " synonymous to " terminal "? I understand that I can read documents about both online. But I believe that an overview

Find and replace variables with SED in a file

孤人 提交于 2019-12-12 06:46:56
问题 I'd would like to find and replace variables in a conf file in KSH (with SED). My question is: what is the correct regex pattern to identify KSH variables (like $toto or ${toto}), by taking into account that variable's name can contains special characters ? Here is an example: Let's say I have var_1=value1 and var_2=value2 in my current shell (grepable in export -p). The configuration file before find and replace PARAM1=$var_1/tata.txt PARAM2=${var_2}/tata.txt The configuration file after

Look for file ksh

烈酒焚心 提交于 2019-12-12 05:49:19
问题 I am trying to learn unix. I wanted to set up a sort of file watcher that looks for files and returns the file names so i can move them from source to processing folder to process. It echos File Found I just cannot figure out how to capture the file name. #determines if file exists if [ -f * ]; then echo "File found" else echo "File not Found" fi # returns file to array #Needs name still NewFiles[0] = #output what what found in 0 index echo "Found File" echo NewFiles[0] 回答1: Assuming the

read column from csv file in terminal ignoring the header

旧城冷巷雨未停 提交于 2019-12-12 05:01:49
问题 I'm writting a simple .ksh file to read a single column from a .csv file and then printing the output to the screen: fname=($(cut -d, -f2 "myfile.csv")) # loop through these names for i in ${fname[@]}; do echo "$i" done This works fine but I don't want to return the header row, that is the first row of the file. How would I alter the cut command so that it ignore the first value or string. In this case the header is called 'NAME'. I want to print all of the other rows of this file. That being

ksh, perform action when reaching loop maximal value

送分小仙女□ 提交于 2019-12-12 04:55:44
问题 I am looking to write a small korn shell script doing 5 tests (by waiting some time before each one) and then, if they all fail, performing an action. I was looking at doing something like : for i in {1..5} do "doMyTest" #it fills a variables "status" (but can unfortunately fails) if [ "$status" ]; then #if status is filled then we can leave the loop break fi sleep 3 #else wait some time before doing another try done if [ -z "$status" ]; then exit 1 fi ... then the rest of my program Do you

expr: non-integer argument while doing Arithmetic in Shell Script [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-12-12 04:55:16
问题 This question already has answers here : Are shell scripts sensitive to encoding and line endings? (5 answers) Closed last year . When i'm trying to execute following line of code #!/bin/sh a=20 b=10 sum=`expr $a + $b` #(i thought i did wrong with ` so i put (') also to check but its becomes literals which gets printed as usual) echo $sum i'm getting the error expr: non-integer argument Can someone tell me where it went wrong in this code because almost on every tutorial same thing was

compare a substring of variable with another string in unix

*爱你&永不变心* 提交于 2019-12-12 04:45:20
问题 I am a beginner in Unix. My apologies if the question sounds too lame. I will be passing an argument to a variable fullstring=$1 . The input for this variable might be something similar to these options, for example tester.txt or tester.sh or testapiece.zip or testing.bad or *.* Basically it is something like the string containing the filename wildcard pattern along with file type. Here I need to cut just the file type from the string that is passed in the argument i.e. basically i need to

Programming in SED or AWK

核能气质少年 提交于 2019-12-12 04:00:05
问题 This is my input file /home/edwprod/dnp >ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//|---/g' -e 's/---|/ |/g' | grep -v "^\." 2>/dev/null |---archive |---bin | |---full_refresh | |---to_be_deleted |---in_dir |---landing | |---archive |---log |---tmp /home/edwprod/dnp > |---dat_profile_backup |---mis | |---export | | |---home | | | |---dss1user | | | | |---audit | | | | |---backup | | | | |---bin | | | | | |---To_b_deleted | | | | | |---to_be_deleted | | | | |---config | | | | |--