Posts
 
Reputation
Joined
Last Seen
Ranked #3K
Strength to Increase Rep
+0
Strength to Decrease Rep
-0
96% Quality Score
Upvotes Received
23
Posts with Upvotes
20
Upvoting Members
15
Downvotes Received
1
Posts with Downvotes
1
Downvoting Members
1
3 Commented Posts
2 Endorsements
Ranked #621
Ranked #505
~25.7K People Reached
Favorite Forums
Favorite Tags

79 Posted Topics

Member Avatar for nikita.

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

Member Avatar for Liam Huang
0
2K
Member Avatar for sheelakumari

does anybody say «hello», and «please» any more ? just «do my stuff», and that's it ? no "hello"? no "please"? no answer !

Member Avatar for parvai
0
340
Member Avatar for Conor_1

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!" ?

Member Avatar for happygeek
-1
161
Member Avatar for Szabi Zsoldos
Member Avatar for Watael
0
1K
Member Avatar for changeworld4u

hi, And, I guess the while loop is useless, because `awk` reads files. Here, it's the `while` loop that reads the file :(

Member Avatar for changeworld4u
0
287
Member Avatar for lewashby
Member Avatar for santakdalai90
Member Avatar for chris.kelley.5015

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 …

Member Avatar for Watael
0
271
Member Avatar for JukesK

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?

Member Avatar for Watael
0
287
Member Avatar for krystosan

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.

Member Avatar for L7Sqr
0
129
Member Avatar for chophouse

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 …

Member Avatar for Watael
0
573
Member Avatar for leghorn

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

Member Avatar for masijade
0
151
Member Avatar for arunkumarch

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

Member Avatar for CrazyDieter
0
269
Member Avatar for duke.tim

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). $ …

Member Avatar for Watael
0
247
Member Avatar for duke.tim
Member Avatar for shamusk

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

Member Avatar for Watael
0
162
Member Avatar for leghorn

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`

Member Avatar for Watael
0
119
Member Avatar for chriswelborn

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`

Member Avatar for chriswelborn
0
390
Member Avatar for leghorn

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 …

Member Avatar for chriswelborn
0
150
Member Avatar for Rahul47

hi, useless use of vi. once the first `vi` is closed, its buffer disappear. instead: cat "$flnm" >> "$dir/$flnm"

Member Avatar for Watael
0
271
Member Avatar for lewashby
Member Avatar for rojomoke
0
248
Member Avatar for old_apache

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

Member Avatar for old_apache
0
185
Member Avatar for old_apache

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.

Member Avatar for old_apache
0
241
Member Avatar for mossman mudas

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') ))"

Member Avatar for mossman mudas
0
162
Member Avatar for saadi068

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.

Member Avatar for Watael
0
240
Member Avatar for sudipta.mml
Member Avatar for boshu
Member Avatar for pooh1234qwerty
Re: awk

hi, `man awk` is very explicit about what is `-F` about what is `NR`, too.

Member Avatar for Watael
0
112
Member Avatar for gtam

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%% *}"

Member Avatar for Watael
0
233
Member Avatar for aditya369

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.

Member Avatar for aditya369
0
368
Member Avatar for malluce

hi, cat is useless. while read line do echo "$line" done < "$filename" your question is not clear: what's the desired output ?

Member Avatar for malluce
0
161
Member Avatar for toldav

hi, where, in your script, do you call the function? it is declared, but you don't seem to call it.

Member Avatar for toldav
0
140
Member Avatar for jo386
Member Avatar for replic
Member Avatar for erezz

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

Member Avatar for erezz
0
210
Member Avatar for manujkathuria

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 …

Member Avatar for L7Sqr
0
115
Member Avatar for lewashby

hi, if [ ${YY} = true ] `$YY` is never true! only `$result` may be false or true, not `$YY`

Member Avatar for lewashby
0
124
Member Avatar for lewashby

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)

Member Avatar for Watael
0
190
Member Avatar for 3e0jUn
Member Avatar for lewashby

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"

Member Avatar for Watael
0
137
Member Avatar for vikarna

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 …

Member Avatar for Watael
0
117
Member Avatar for akileshb

hi, don't! `s` stands for 'secure'; using clear passwords in a script is not secure. use public key authentication.

Member Avatar for Taywin
0
360
Member Avatar for lena1990
Member Avatar for it@61@sec

hi, `&` has to be protected (it's a metacharacter), either using (single )quotes, or slash: echo 'param&ext' echo "param&ext" echo param\&ext

Member Avatar for it@61@sec
0
970
Member Avatar for jpreem
Member Avatar for ms061210
Member Avatar for vikarna
Member Avatar for lena1990

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?

Member Avatar for Watael
0
97
Member Avatar for lena1990

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

Member Avatar for Watael
0
98
Member Avatar for Ashley1966

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 …

Member Avatar for Watael
0
113

The End.