sh

Temporarily clear the terminal in Linux

折月煮酒 提交于 2019-12-12 04:52:44
问题 I want to write a GUI/Terminal based application where I would need to clear the terminal and then write out the gui. But how do I reset the terminal back to normal once the application is finished? 回答1: Terminals (such as xterm and "any" which emulate it) support a feature called the alternate screen. Often, terminal descriptions include switching to/from the alternate screen in the smcup and rmcup capabilities, and it is used by ncurses applications. (The feature is not always used, because

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

Searching images with Googliser.sh in Mac: “ls: illegal option — I”

感情迁移 提交于 2019-12-12 03:29:05
问题 I have a question over the script Googliser and the Mac commands. I tried the script some days ago in the Mac shell and made it work. I followed the script listed here: brew install wget brew install gnu-getopt brew link --force gnu-getopt curl -sO https://raw.githubusercontent.com/teracow/googliser/master/googliser.sh sed -i "" "s/readlink/stat/;s/dev\/shm/tmp/;s/p -p/p -t/" googliser.sh chmod +x googliser.sh Easy. It worked, not the first time, and I don't remember how I made it work. But

Need some help on shell scipt (using grep command)

此生再无相见时 提交于 2019-12-12 03:16:31
问题 I have a log file and I am trying to write a shell script to find multiple strings in a file on multiple lines. For example if I see the phrases "class=com.comcast.parker.GetCurrentAudioLanguageResponse" and "status:OK" together in the logs, I should print getAudioLanguage SUCCESSFUL else getAudioLanguage FAILED. So my shell script goes like this: Scriptfile: logfile=$1 if grep "{\"class\":\"com.comcast.parker.GetCurrentAudioLanguageResponse\"" jags.txt | grep "{\"status\":\"OK\"" | wc -l ;

My Bash script doesn't respond to SIGNALS when opening new shell session

℡╲_俬逩灬. 提交于 2019-12-12 02:08:52
问题 I have this simple bash script: #!/bin/bash trap "rm /testfile; service apache2 stop;" SIGTERM service apache2 start # Here I want to create new bash session for some reasons. /bin/bash Now some another program can somewhen send SIGTERM to this script, but actually the script does NOT respond to that signal, it keeps hanging in the new bash session , the same case when I use something else like sleep infinity instead of opening new bash session (that was just for testing because I need that

Why would a correct shell script give a wrapped/truncated/corrupted error message? [duplicate]

爷,独闯天下 提交于 2019-12-12 01:38:14
问题 This question already has answers here : Are shell scripts sensitive to encoding and line endings? (5 answers) Closed last year . I have a shell script with a command that seems like it should work, but instead it fails with an odd wrapped/truncated/corrupted error message. Example: $ ls -l myfile -rw-r----- 1 me me 0 Aug 7 12:36 myfile $ cat myscript ls -l myfile $ bash myscript : No such file or directory The file clearly exist, but even if I didn't, this is the kind of error message I

redirecting in a shell script

荒凉一梦 提交于 2019-12-12 00:43:39
问题 I'm trying to write a script to swap out text in a file: sed s/foo/bar/g myFile.txt > myFile.txt.updated mv myFile.txt.updated myFile.txt I evoke the sed program, which swaps out text in myFile.txt and redirects the changed lines of text to a second file. mv then moves .updated txt file to myFile.txt, overwriting it. That command works in the shell. I wrote: #!/bin/sh #First, I set up some descriptive variables for the arguments initialString="$1" shift desiredChange="$1" shift document="$1"

bash - The Best Elegant way to disable log file

最后都变了- 提交于 2019-12-11 22:26:57
问题 dear friends and colleges the following code , is the basic concept of my log file in my bash script this Code help me to understand each step in my bash script or in case we need to make troubleshooting but some times I want to disable the Log creation because we not need the log and want to make the script more efficiency ( call to Log function each line in the script take time and make the script more heavy ) so my question my friends: What the best elegant way to disable the log file?

How do we build Normalized text file from DeNormalized one?

99封情书 提交于 2019-12-11 20:23:31
问题 Thanks for your replies/time. We need to build a Normalized text file from DeNormalized text file . We explored couple of options such as unix shell , and Loading into data base etc. I am looking pick up better ideas for resolutions from this community. The input text file is various length with comma delimited records. The content may look like this: **XXXXXXXXXX , YYYYYYYYYY, TTTTTTTTTTT, UUUUUUUUUU, RRRRRRRRR,JJJJJJJJJ 111111111111, 22222222222, 333333333333, 44444444, 5555555, 666666

How to store STDOUT buffer of `mysql_secure_installation` to a file

寵の児 提交于 2019-12-11 19:35:29
问题 I want to append STDOUT or STDERR of command mysql_secure_installation to a file for example /tmp/output.txt but no success on below commands: mysql_secure_installation >> /tmp/output.txt mysql_secure_installation 1>> /tmp/output.txt mysql_secure_installation 2>> /tmp/output.txt Also tested STDIN and reserved buffers by below commands: mysql_secure_installation 0>> /tmp/output.txt mysql_secure_installation 3>> /tmp/output.txt ... mysql_secure_installation 9>> /tmp/output.txt It seems mysql