- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 23
- Posts with Upvotes
- 20
- Upvoting Members
- 15
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
79 Posted Topics
Re: hi, awk -F'|' '{ for(n=1; n<=NF; n++){ if(n!=NF)fmt="%s|"; else fmt="%s\n" if(n!=4)printf(fmt,$n) } }' UrFile | |
Re: does anybody say «hello», and «please» any more ? just «do my stuff», and that's it ? no "hello"? no "please"? no answer ! | |
Re: no hello? no please? no answer! do you really want to live in such a world; where people come, put their stuff on the table, and say "do it!" ? | |
Re: this also is why 'ls' should be avoided in shell script; instead use 'stat'. | |
Re: hi, And, I guess the while loop is useless, because `awk` reads files. Here, it's the `while` loop that reads the file :( | |
Re: string=123456789 echo ${string: -3} 789 | |
Re: hi, pgrep -c XYZ.sh that's it! XD | |
Re: hi, `less` gives no output to `sed` ! This is how to read a file : while read line do echo "$line" done < file now, if you want to split line into fields, tell the `IFS` (Internal Field Separator) what separator to use: while IFS=':' read firstField secondField otherFields … | |
Re: hi, $ TS20="710000/393" $ echo "$TS20" 710000/393 how do get variables from txt file? I'm not sure it's a bash problem, but rather a php one. Did you test bash script without being called in php? | |
Re: hi krystosan, what if you start from the beginning? what list are talking about? does the <command> take a list of arguments, or does it take only one argument, and so have to be executed many times? and so on. | |
Re: hi, for ((n=0; n<24*60;n+=72)); do date -d "00:00 $n min" +%H\ %M; done |\ awk 'BEGIN{PROCINFO["sorted_in"]="@ind_num_asc"} {$1=$1?$1:"00";a[$2]=a[$2]?a[$2]","$1:$1} END{for(i in a)printf("%d\t%s\t* * *\tcmd-to-run\n", i, a[i])}' 0 00,06,12,18 * * * cmd-to-run 12 01,07,13,19 * * * cmd-to-run 24 02,08,14,20 * * * cmd-to-run 36 03,09,15,21 * * * cmd-to-run 48 04,10,16,22 … | |
Re: hi, > use a for loop over a cat command and read the lines no! that's UUOC (at least). while read -r line; do echo "$line"; done <file >newFile mv newFile file | |
Re: hi, uuoc (useless use of cat) uuot (useless use of test) if grep -q ^"$1" /etc/passwd then echo "user $1 exists" else echo "user $1 does not exist" exit 1 fi | |
Re: hi, that's silly coding :( var="input this to be parsed and placed into an array" array=( $var ) printf '%s\n' "${array[@]}" that's all. an array is like any other variable: if not defined as local, they're global (exept associative arrays which need to be declared, and declared as global). $ … | |
Re: `cat whois$query` give file its (full) path! | |
Re: > Also how to you call an awk script from within a C program ?? that doesn't make sense. If you can C, then what you're asking for shouldn't be too difficult to do with C. please be more precise about what you've got to do. not only the way … | |
Re: hi, `[` is an alias for `test`, it's useless here. try this way: if $DISPLAY xstatus | grep "$right...$right" then echo ok else echo ko fi and `man which` to know what does `which frsh` | |
Re: hi `printf` with an f, like format. it should be used to separate format from data. Array of strings : use more quotes: `"${array[@]}"`, in case element has space(s) in it. All files _and directories_, in current directory. Arguments, `in @` is not needed : `for i do :etc; done` | |
Re: hi, > why does my script work as sh script.sh and not as ./script.sh ? has your script been made executable ? > my pattern is king, and there are 4 "king"s in the txt file .. also there are two "taking"s .. shouldnt the count be 6? m getting … | |
![]() | Re: hi, useless use of vi. once the first `vi` is closed, its buffer disappear. instead: cat "$flnm" >> "$dir/$flnm" |
Re: hi, v="myFile.cpp" ((${#v}>4)) && echo "${v:: -4}" or v="myFile.cpp" echo "${v%.cpp}" | |
Re: > how do i do that? I'd say «just do it!» ;) both systems do not end lines the same way. you'll probably have to remove carriage return from windows files by using `fromdos`. it's possible to do it with `tr`, or `sed` too. | |
Re: hi, $ var="96.33% from 120" $ echo "${var%\%*}" 96.33 this is POSIX parameter expansion. as you see, as `%` is a special character for *Parameter Expansion* (see man bash), so it has to be protected. | |
Re: hi, from `du --help` : -s, --summarize display only a total **for each argument** so, as each given filename is an argument... find's `-printf` can print files size. you could use bash to sum files size like this: echo $(( $(find . -type f -user $USER -printf '+%s') ))" | |
Re: hi, have an eye (at least) at these documents : [BASH Programming HOWTO](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html#toc3) [Advance Bash Scripting](http://tldp.org/LDP/abs/html/index.html) then show what you've tried, and tell where you're stuck. | |
Re: sed "s/PW 30903/PW $no_water/;s/CL- 1/CL- $length/" arg01.top >arg$length.top | |
Re: hi, «is not working right» is not very descriptive. | |
Re: hi, `man awk` is very explicit about what is `-F` about what is `NR`, too. | |
Re: hi, first, you could avoid `eval` by using an assosciative array. next, remove parenthesis from "improved test" (`[[`); you could also use simple `test`. finally, remove trailing spaces and dash from `checksum`s checksum="${checksum%% *}" | |
Re: hi, awk is the tool. it uses associative arrays, which subscript could be the string, and which value could be incremented if subscript isn't in array. so, if string is in array, then change string with array's value else increment value. | |
Re: hi, cat is useless. while read line do echo "$line" done < "$filename" your question is not clear: what's the desired output ? | |
Re: hi, where, in your script, do you call the function? it is declared, but you don't seem to call it. | |
Re: hi, if test -n "$1" and, as you can see, use more quotes. | |
Re: hi, can you show the result of this command cat -A numbers.txt | |
Re: hi, are you sure you need all these informations in the file list? wouldn't you use `stat` to keep only useful informations, instead of `ls -nh`? | |
Re: hi, it depends on how you intend to scp files if you scp them all at one time, a bit like you'd copy recusrsively directories, AFAIK you can't tell. if you copy file on at a time, using a loop, you could echo filenames to a log file when scp … | |
Re: hi, if [ ${YY} = true ] `$YY` is never true! only `$result` may be false or true, not `$YY` | |
Re: hi, you're using `test` builtin operators inside `expr` expression. `expr` is useless external command: bash can do arithmetic evaluation (see man bash /^ARITHMETIC EVALUATION) | |
Re: did you read `sshd`'s man page? | |
Re: hi, no need of a function, bash parameter substitution can do it: read -p' enter date: ' Date test ${#Date} -eq 8 || s=" not" echo "$Date is$s 8 chars" | |
Re: hi, you need to concatenate lines based on their position after a pettern. use an array which index is reset when ABCD# is met, and incremented for each line. more or less if line == ABCD# then reset index else array[index++]=array[index]" "line endif what language do intend to use? how … | |
Re: hi, don't! `s` stands for 'secure'; using clear passwords in a script is not secure. use public key authentication. | |
Re: show what you've done. all our cristal balls are broken ;) | |
Re: hi, `&` has to be protected (it's a metacharacter), either using (single )quotes, or slash: echo 'param&ext' echo "param&ext" echo param\&ext | |
Re: so, you're missing the `do`, in the `for var in list; do :....; done` | |
Re: hi, te.txt is probably not right under the root directory (`/`), but under the current directory: `./` btw, your code seems silly, what are you trying to do? | |
Re: > i want to create a shell script good for you > divide a text file to parts based on what? > take the information from each part and store it where? show input, and desired output! | |
Re: the first for loop is useless. your script is as messy as your post. once you're on the server side, you can't go back to the client and again back to the server. the "script" is sent and executed on the server. don't use `ls` inside scripts, the shell has … |
The End.