bash4

How to change current working directory inside command_not_found_handle

ⅰ亾dé卋堺 提交于 2019-12-05 16:05:14
I'm trying to write a not found handle in Bash that does the following: If $1 exists and it's a directory, cd into it. If $1 exists inside a user defined directory $DEV_DIR , `cd into it. If the previous conditions don't apply, fail. Right now I have something like this: export DEV_DIR=/Users/federico/programacion/ function command_not_found_handle () { if [ -d $1 ]; then # the dir exists in '.' cd $1 else to=$DEV_DIR$1 if [ -d $to ]; then cd $to echo `pwd` else echo "${1}: command not found" fi fi } And although it seems to be working (the echo pwd command prints the expected dir), the

What ncurses frameworks are available for BASH? [duplicate]

自古美人都是妖i 提交于 2019-12-04 12:39:17
问题 This question already has answers here : Bash script with graphical menus (2 answers) Closed 2 years ago . Are there some more Text User Interface (TUI) frameworks for bash (other than this)? : http://code.google.com/p/bashsimplecurses/ I want to take user input (data entry) process the entry 回答1: If all you need to do is prompt the user for information, take a look at dialog . http://invisible-island.net/dialog/dialog.html 回答2: bashsimplecurses is pretty capable (from the little I've seen),

What ncurses frameworks are available for BASH? [duplicate]

余生颓废 提交于 2019-12-03 08:10:13
This question already has answers here : Bash script with graphical menus (2 answers) Are there some more Text User Interface (TUI) frameworks for bash (other than this)? : http://code.google.com/p/bashsimplecurses/ I want to take user input (data entry) process the entry If all you need to do is prompt the user for information, take a look at dialog . http://invisible-island.net/dialog/dialog.html Agi Hammerthief bashsimplecurses is pretty capable (from the little I've seen), but you might want to try GTK Server . (Have a look at the docs page for tutorial and manual links). It can work with

qstat and long job names

老子叫甜甜 提交于 2019-12-03 05:30:43
问题 How can I get qstat to give me full job names? I know qstat -r gives detailed information about the task, but it's too much and the resource requirements are included. The qstat -r output is like: 131806 0.25001 tumor_foca ajalali qw 09/29/2014 15:49:41 1 2-100:1 Full jobname: tumor_focality-TCGA-THCA-ratboost_linear_svc Hard Resources: distribution=wheezy (0.000000) h_rt=72000 (0.000000) mem_free=15G (0.000000) h_vmem=15G (0.000000) h_stack=256M (0.000000) Soft Resources: 131807 0.25001

How to run BASH script in my Android?

南笙酒味 提交于 2019-12-03 04:22:59
问题 My same BASH script is working in Fedora/CentOS. But I am testing one Android eee pad transformer . Where i have terminal access and i wrote a small test script. But its not working, how can i fix it? what am i doing wrong? /data/data/berserker.android.apps.sshdroid/home $ cat test.sh #!/bin/bash var=`ifconfig -a`; echo $var; /data/data/berserker.android.apps.sshdroid/home $ chmod +x test.sh /data/data/berserker.android.apps.sshdroid/home $ ./test.sh sh: ./test.sh: not found /data/data

qstat and long job names

自古美人都是妖i 提交于 2019-12-02 18:47:56
How can I get qstat to give me full job names? I know qstat -r gives detailed information about the task, but it's too much and the resource requirements are included. The qstat -r output is like: 131806 0.25001 tumor_foca ajalali qw 09/29/2014 15:49:41 1 2-100:1 Full jobname: tumor_focality-TCGA-THCA-ratboost_linear_svc Hard Resources: distribution=wheezy (0.000000) h_rt=72000 (0.000000) mem_free=15G (0.000000) h_vmem=15G (0.000000) h_stack=256M (0.000000) Soft Resources: 131807 0.25001 vital_stat ajalali qw 09/29/2014 15:49:41 1 2-100:1 Full jobname: vital_status-TCGA-LGG-ratboost_linear_svc

How to run BASH script in my Android?

守給你的承諾、 提交于 2019-12-02 17:37:42
My same BASH script is working in Fedora/CentOS. But I am testing one Android eee pad transformer . Where i have terminal access and i wrote a small test script. But its not working, how can i fix it? what am i doing wrong? /data/data/berserker.android.apps.sshdroid/home $ cat test.sh #!/bin/bash var=`ifconfig -a`; echo $var; /data/data/berserker.android.apps.sshdroid/home $ chmod +x test.sh /data/data/berserker.android.apps.sshdroid/home $ ./test.sh sh: ./test.sh: not found /data/data/berserker.android.apps.sshdroid/home $ uname -a Linux localhost 2.6.36.3-00004-g069b8b5 #1 SMP PREEMPT Wed

Multiple matches in a string using regex in bash

时光怂恿深爱的人放手 提交于 2019-12-01 22:15:36
问题 Been looking for some more advanced regex info on regex with bash and have not found much information on it. Here's the concept, with a simple string: myString="DO-BATCH BATCH-DO" if [[ $myString =~ ([[:alpha:]]*)-([[:alpha:]]*) ]]; then echo ${BASH_REMATCH[1]} #first perens echo ${BASH_REMATCH[2]} #second perens echo ${BASH_REMATCH[0]} #full match fi outputs: BATCH DO DO-BATCH So fine it does the first match (BATCH-DO) but how do I pull a second match (DO-BATCH)? I'm just drawing a blank

bash: iterating through txt file lines can't read last line

笑着哭i 提交于 2019-12-01 22:09:51
问题 while read p; do echo $p done < file.txt this code can read all lines in the file.txt except the last line any ideas why. Thanks 回答1: if youre in doubt about the last \n in the file, you can try: while read p; do echo $p done < <(grep '' file.txt) grep is not picky about the line endings ;) you can use grep . file.txt for skipping empty lines... 回答2: Well last line does not contain the newline character, as the other answers have pointed out. But the read command actually sets the p variable,

bash: iterating through txt file lines can't read last line

孤人 提交于 2019-12-01 20:58:13
while read p; do echo $p done < file.txt this code can read all lines in the file.txt except the last line any ideas why. Thanks if youre in doubt about the last \n in the file, you can try: while read p; do echo $p done < <(grep '' file.txt) grep is not picky about the line endings ;) you can use grep . file.txt for skipping empty lines... Well last line does not contain the newline character, as the other answers have pointed out. But the read command actually sets the p variable, and then instead of returning a success, returns an end of file error. So this error stops the loop from getting