sh

Getting Webpage Title, Img, Metadata info from Linux Terminal

泄露秘密 提交于 2019-12-13 06:26:18
问题 is there any way or any tools that I could use to get from a SH script, a webpage title, metadata such as descriptions, maybe a little screenshot of the webpage or anything like that? Thanks in advance! 回答1: you could use curl or wget to get the webpage, and then pipe it to sed to get the contents of various tags. It's kludgy as , but that's kinda what you're going to get if you're doing this stuff with a shell script. eg wget http://example.com -O - | grep \<title\>|sed "s/\<title\>\([^<]*\)

Linux how to make the space similar with previous

天涯浪子 提交于 2019-12-13 05:25:12
问题 I have an input and which to replace certain (row,column) . I have done to replace the (row,Columnn) that needed but how come the whole line formate was shift? Any code need to add in to prevent the format changes? Code that i am using to replace the (row,column) cat abc.txt | awk '$1 ~/^0(1?[0-9])|^00(1?[0-9])$/' | awk '{ if (NR==2) $8="9" ;if ($8 == "9") $66="9";print}' Input File 024 1 1 1 1 1 1 1 1 1 1 248 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

bash to sh (ash) spoofing

感情迁移 提交于 2019-12-13 05:03:41
问题 I have a 3rd party generator that's part of my build process (sbt native packager). It generates a bash script to be used to run my built program. Problem is I need to use sh (ash), not bash. So the generator cranks out a line like this: declare -a app_mainclass=("com.mypackage.Go") sh chokes on this as there is no 'declare' command. Clever me--I just added these lines: alias declare='' alias '-a'='' This worked on all such declarations except this one--because of the parens. sh apparently

Using $# in bash loops

早过忘川 提交于 2019-12-13 04:35:30
问题 I am trying to understand why this loop does not print a number for each arguments supplied to the script. #!/bin/bash for i in {1..$#}; do echo $i done Instead, when supplied e.g. 3 arguments, it outputs {1..3} 回答1: The expression {} does not accept variables. To do so, you need to work with for example seq . The following will make it:: #!/bin/bash for i in $(seq 1 $#); do echo $i done Note that $() is equivalent to `` . That is, it performs a command substitution. For example: $ d=$(echo

rename file in bourne shell

跟風遠走 提交于 2019-12-13 04:09:10
问题 I am trying to write a bourne-shell script that takes a directory as a parameter and look for images named ixxx.a and rename them to ixxx_a.img where "xxx means the extension number for exemple image files would be named i001.a , i002.a ,i003.a ...) here what I tried mv $1/f[0-9][0-9][0-9].a $1/f[0-9][0-9][0-9]_a.img but it says that the DEST is not a directory. Any help would be much appreciated. Thanks. 回答1: for i in $1/f[0-9][0-9][0-9].a; do mv $i ${i%.a}_a.img done However, this does not

scp: how to find out that copying was finished

白昼怎懂夜的黑 提交于 2019-12-13 03:58:30
问题 I'm using scp command to copy file from one Linux host to another. I run scp commend on host1 and copy file from host1 to host2. File is quite big and it takes for some time to copy it. On host2 file appears immediately as soon as copying was started. I can do everything with this file even if copying is still in progress. Is there any reliable way to find out if copying was finished or not on host2? 回答1: Off the top of my head, you could do something like: touch tinyfile scp bigfile tinyfile

Execute shell script in a zip archive

こ雲淡風輕ζ 提交于 2019-12-13 03:52:48
问题 I have a huge folder in a Linux system. Within it, I have a zip archive that encloses a couple of shell scripts. I need to execute these shell scripts, but the challenge is that I don't have write access to this folder. Also, I cannot move it to other directory either, since the location of this file is critical to its execution. It won't work in any other directory. Is there any way to execute the shell script from within the zip archive without extracting it? 回答1: You can unzip one specific

iOS Pre-build action to change plist value based on Scheme

不打扰是莪最后的温柔 提交于 2019-12-13 03:48:05
问题 I have an iOS application that is using the Agentry framework to define the Agentry server URL to connect. The agentryServerURL parameter is included in a separate branding.plist file as per the SAP specs. What I am trying to do is tie my iOS schemes for the different environments to a pre-build action in order to change the Agentry URL value. Here is my current script but it is not working. #!/bin/sh plist=$SRCROOT"/branding.plist" if [ ${CONFIGURATION} = "DEV" ]; then /usr/libexec

What is the regex matching operator in bourne shell script?

走远了吗. 提交于 2019-12-13 03:44:38
问题 I am trying to validate user input against a regular expression. vari=A if [ $vari =~ [A-Z] ] ; then echo "hurray" fi The output I am getting is swf.sh[3]: =~: unknown test operator. Can you please let me know the test operator I can use? 回答1: It's not built into Bourne shell, you need to use grep: if echo "$vari" | grep -q '[A-Z]'; then echo hurray fi If you want to match the whole string, remember to use the regex anchors, ^ and $ . Note that the -q flag makes grep quiet, so its only output

can't send ' on groovy sh command

ε祈祈猫儿з 提交于 2019-12-13 03:09:49
问题 Hi all I have pipeline on jenkins and I try to execute some sh command sh script: "cd /home/jenkins/workspace/automation-pipeline/ConvertedJSfiles/ && protractor conf.js -suite ${suiteTestss} --params.data='${data2}' --params.description='${params.description}' --params.jenkins_build_number=${currentBuild.number}" from some reason the ' erase on execute command and I can not successfully send strings with spaces as parameters on the operation example of wrong output cd /home/jenkins/workspace