scripting

How to iterate over text file having multiple-words-per-line using shell script?

北战南征 提交于 2020-01-30 08:30:25
问题 I know how to iterate over lines of text when the text file has contents as below: abc pqr xyz However, what if the contents of my text file are as below, abc xyz cdf pqr lmn rst and I need to get values "abc" stored to one variable and"xyz" stored to another variable. How would I do that? 回答1: If the delimiter is a space then you can do: #!/bin/bash ALLVALUES=() while read line do ALLVALUES+=( $line ) done < "/path/to/your/file" So after, you can just reference an element by ${ALLVALUES[0]}

How to iterate over text file having multiple-words-per-line using shell script?

∥☆過路亽.° 提交于 2020-01-30 08:30:25
问题 I know how to iterate over lines of text when the text file has contents as below: abc pqr xyz However, what if the contents of my text file are as below, abc xyz cdf pqr lmn rst and I need to get values "abc" stored to one variable and"xyz" stored to another variable. How would I do that? 回答1: If the delimiter is a space then you can do: #!/bin/bash ALLVALUES=() while read line do ALLVALUES+=( $line ) done < "/path/to/your/file" So after, you can just reference an element by ${ALLVALUES[0]}

Shell script to capture Process ID and kill it if exist [duplicate]

六眼飞鱼酱① 提交于 2020-01-27 03:21:48
问题 This question already has answers here : Find and kill a process in one line using bash and regex (25 answers) Closed 3 years ago . I tried this code and it is not working #!/bin/sh #Find the Process ID for syncapp running instance PID=`ps -ef | grep syncapp 'awk {print $2}'` if [[ -z "$PID" ]] then Kill -9 PID fi It is showing a error near awk. Any suggestions please. 回答1: Actually the easiest way to do that would be to pass kill arguments like below: ps -ef | grep your_process_name | grep

Deleting contents of W2K3 recycle bin

耗尽温柔 提交于 2020-01-25 22:52:51
问题 Writing a Powershell script that deletes all the contents from the recycle bins for virtual servers. For some reason I'm running into an error with finding the path for the Windows 2003 recycle bin and can't locate bin in order to delete everything in it. Was wondering if anyone here could give me some advice on what I am doing wrong with this code-snippet: if($serverVersion.name -like '*2003*'){ $dir = "\\$server" + '\C$\recycled' } elseif($serverVersion.name -like '*2008*'){ $dir = "\\

.lldbinit doesn't work in xCode

社会主义新天地 提交于 2020-01-25 02:57:08
问题 .lldbinit was used to preload some scripts before xCode start. The goal of this file is to load some script code automatically. Many people recommend it but it DOESN'T WORK . I know the script code is correct because it works on manual call: command source ~/.lldbinit Does it work no more? I tried the following simple code in xCode 6.4: expr @import UIKit Any solutions except of breakpoints calling this script manually? 回答1: The .lldbinit in your home directory is sourced in BEFORE the target

.lldbinit doesn't work in xCode

一世执手 提交于 2020-01-25 02:57:06
问题 .lldbinit was used to preload some scripts before xCode start. The goal of this file is to load some script code automatically. Many people recommend it but it DOESN'T WORK . I know the script code is correct because it works on manual call: command source ~/.lldbinit Does it work no more? I tried the following simple code in xCode 6.4: expr @import UIKit Any solutions except of breakpoints calling this script manually? 回答1: The .lldbinit in your home directory is sourced in BEFORE the target

Run Powershell script via batch file with elevated privileges

谁说胖子不能爱 提交于 2020-01-24 22:20:21
问题 I need to run a Powershell script to create AD user via a batch file. The thing is I need to run this PS script with elevated privileges (domain admin account). I have tried to script a '.bat' file which encloses all this information but I have been unsuccessful so far. Here is the script : echo off cls echo Sign in with your ADM ID set /p username= powershell -noprofile -command "&{ start-process powershell -ArgumentList '- noprofile -file C:\Users\...\Desktop\Powershell_scripts\New-ADuser

Shell script to rename multiple files from their parent folders name

与世无争的帅哥 提交于 2020-01-24 16:47:45
问题 I have a file structure like this: 00000010 000000001.file1 000000001.file2 00000020 00000003.file1 00000003.file2 00000003.file3 ... So there are folders with 8-digit names containing one ore more files with name starting with 8-digit numbers. But theses filenames are – let's say – out of sync. So Now I try to rename them recursively in bash to archive: 00000010 000000010.file1 000000010.file2 00000020 00000020.file1 00000020.file2 00000020.file3 ... My script does look like: #! /bin/bash

Shell script to rename multiple files from their parent folders name

百般思念 提交于 2020-01-24 16:47:45
问题 I have a file structure like this: 00000010 000000001.file1 000000001.file2 00000020 00000003.file1 00000003.file2 00000003.file3 ... So there are folders with 8-digit names containing one ore more files with name starting with 8-digit numbers. But theses filenames are – let's say – out of sync. So Now I try to rename them recursively in bash to archive: 00000010 000000010.file1 000000010.file2 00000020 00000020.file1 00000020.file2 00000020.file3 ... My script does look like: #! /bin/bash

Can Netsuite Suitescript modify a file in the file cabinet?

廉价感情. 提交于 2020-01-24 15:15:07
问题 I have a large product list and need to generate a static file of it, and have that file be accessible in my website. Currently, I generate the list, and upload it to the file cabinet. I wish to automate this process. I would like to schedule a SuiteScript to run each night and generate this list and update a file in the file cabinet. Can this be done? thanks 回答1: You can automate this process with SuiteScript. You would use the nlapiLoadFile and nlapiSubmitFile calls to accomplish it. If you