Unix/Linux Go Back    

Showing results 1 to 25 of 500
Search took 0.15 seconds.
Search: Posts Made By: Scrutinizer
Forum: Shell Programming and Scripting Linux 3 Hours Ago
Replies: 3
Views: 632
Posted By Scrutinizer
How about: sed 's/ */,/; s/ */,/' file ...

How about:
sed 's/ */,/; s/ */,/' file


or a different approach:

awk '!/---/{$3=$3 FS $4 FS $5; $4=$5=x; sub(/,+$/,x)}1' OFS=, file


---
Forum: UNIX for Beginners Questions & Answers Linux 19 Hours Ago
Replies: 6
Views: 112
Posted By Scrutinizer
Oww that is right, Try: FNR==1{ incr=NF/12 } ...

Oww that is right,
Try:
FNR==1{ incr=NF/12 }
If NF is the same for every line in the file

In the BEGIN section NF is not yet initialized..

And remove the NR>1 condition

So:
Forum: UNIX for Beginners Questions & Answers Linux 19 Hours Ago
Replies: 6
Views: 112
Posted By Scrutinizer
Try: print incr awk does not use a $ sign to...

Try:
print incr
awk does not use a $ sign to get the value stored in the variable..
Forum: Shell Programming and Scripting Linux 1 Day Ago
Replies: 3
Views: 175
Posted By Scrutinizer
You are using a while read loop that takes the...

You are using a while read loop that takes the input of the file. So it echoes the 5 output lines x the number of lines in the file, so there appear to be 4 lines in the file.

Just leave out the...
Forum: UNIX for Beginners Questions & Answers Linux 1 Day Ago
Replies: 5
Views: 150
Posted By Scrutinizer
What does not work? What does the script do? A...

What does not work? What does the script do? A difference is that you are in a different directory. If inside the script you are writing a file to a relative path that might make a difference for...
Forum: Shell Programming and Scripting Linux 3 Days Ago
Replies: 11
Views: 306
Posted By Scrutinizer
This is not doing what you require: elif [[...

This is not doing what you require:
elif [[ "$lastseen" = '^[a-ZA-Z]*$' ]] || [[ -z "$lastseen" ]];
See Parsing null or empty output: post #4 (https://www.unix.com/303009136-post4.html)

This...
Forum: UNIX for Beginners Questions & Answers Linux 3 Days Ago
Replies: 4
Views: 134
Posted By Scrutinizer
Hi, try: awk -v n=3 '{for(i=2; i<=n; i++)...

Hi, try:
awk -v n=3 '{for(i=2; i<=n; i++) $i=$1}1' file.txt > newfile.txt
The counter needs to be reset for every line..
Forum: UNIX for Beginners Questions & Answers Linux 6 Days Ago
Replies: 6
Views: 339
Posted By Scrutinizer
If the requirement is that only digits may occur,...

If the requirement is that only digits may occur, you can test for the negation of a string of 1 or more digits instead:
if ! [[ $lastseen =~ ^[0-9]+$ ]]; then
echo "Serial Number is invalid: it...
Forum: Shell Programming and Scripting Linux 6 Days Ago
Replies: 7
Views: 296
Posted By Scrutinizer
Try something like this: ( DISPLAY=:0...

Try something like this:
( DISPLAY=:0 xfce4-terminal --command /bin/bash -c "echo hello; sleep 10" & )
Forum: Shell Programming and Scripting Linux 6 Days Ago
Replies: 7
Views: 296
Posted By Scrutinizer
Here documents require that EOF is at the start...

Here documents require that EOF is at the start of the on a separate line and that is the only text on the line, so using you code as an example, you would need something like this

cat <<EOF...
Forum: UNIX for Beginners Questions & Answers Linux 1 Week Ago
Replies: 5
Views: 181
Posted By Scrutinizer
Also, since the first line has a space in front...

Also, since the first line has a space in front of the shebang on the first line, it would not work even if you call the script without specifying a shell when calling the script. The shebang only...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 4
Views: 243
Posted By Scrutinizer
If you are using bash, ksh93 or zsh, you could do...

If you are using bash, ksh93 or zsh, you could do something like this
read v1 v2 dummy < <(cksum sjreas.py)

---
The reason you get a trailing space in your variable may also be because of the...
Forum: Shell Programming and Scripting Linux 1 Week Ago
Replies: 7
Views: 317
Posted By Scrutinizer
That presumably is because getent passwd takes...

That presumably is because getent passwd takes both uid and user name as parameter and has to make a decision which one is the case, where all-numeric is likely deemed a uid ...

With yp commands...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 7
Views: 317
Posted By Scrutinizer
Perhaps something like this: #!/bin/bash ...

Perhaps something like this:
#!/bin/bash
linefmt="%-8s%-13s%s\n"
bjobs "$@" |
{
read jobid uid rest
printf "$linefmt" "$jobid" "$uid" "$rest"
while read line
do
if [[ $line ==...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 6
Views: 292
Posted By Scrutinizer
For step 2, how about something like: cmd=$(awk...

For step 2, how about something like:
cmd=$(awk -F, '{gsub(/^"|"" "$/, "", $16); print $16}' AWS.CSV)
start_time=$(date -d '-1 minute')
$cmd; $cmd; $cmd
end_time=$(date -d '+1 minute')

Note 1:...
Forum: Shell Programming and Scripting Linux 2 Weeks Ago
Replies: 6
Views: 292
Posted By Scrutinizer
First step, try: awk -F, '{gsub(/^"|"" "$/, "",...

First step, try:
awk -F, '{gsub(/^"|"" "$/, "", $16); print $16}' file
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 6
Views: 239
Posted By Scrutinizer
With bash3 or up, zsh and a recent ksh93, you can...

With bash3 or up, zsh and a recent ksh93, you can also use pipefail:
$ set -o pipefail; false | true ; echo "$?"
1

On Solaris 10, what shells/versions do you have available?
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 7
Views: 281
Posted By Scrutinizer
When I copy and paste your samples into a file it...

When I copy and paste your samples into a file it works fine. When I remove one of the lines of input.txt, the corresponding line in file.txt gets printed. Could you try that yourself?

Also, make...
Forum: UNIX for Beginners Questions & Answers Linux 3 Weeks Ago
Replies: 4
Views: 152
Posted By Scrutinizer
Hi, try: awk -F, '$1~96656' STG3TOUDCMATCH >>...

Hi, try:
awk -F, '$1~96656' STG3TOUDCMATCH >> 56_Ser
Forum: UNIX for Beginners Questions & Answers Linux 3 Weeks Ago
Replies: 10
Views: 362
Posted By Scrutinizer
@abhilashnair, could you answer the Don Cragun's...

@abhilashnair, could you answer the Don Cragun's questions in post #2. Then we could likely provide you with a better answer.
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 8
Views: 367
Posted By Scrutinizer
Hi, try: (!($4 in CHR)) rather than (! $4 in...

Hi, try:
(!($4 in CHR)) rather than (! $4 in CHR)
Forum: UNIX for Advanced & Expert Users Linux 3 Weeks Ago
Replies: 2
Views: 173
Posted By Scrutinizer
Like this ? rpm -qi some_package | grep...

Like this ?
rpm -qi some_package | grep ^Install


---
or, for multiple packages at once, try:
pkgs=( package1 package2 package 3 )
rpm -qi "${pkgs[@]}" | grep -E '^(Name|Install)' | paste - -
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 9
Views: 403
Posted By Scrutinizer
Just for fun, another one: sed 's/../& /g' file...

Just for fun, another one:
sed 's/../& /g' file | xargs -n 3
Forum: Shell Programming and Scripting Linux 3 Weeks Ago
Replies: 16
Views: 402
Posted By Scrutinizer
@jim: but the red curly brace (the second closing...

@jim: but the red curly brace (the second closing brace) should be there, no?
It is present in the code in both post #1 and post #3 ...
Forum: Shell Programming and Scripting Linux 4 Weeks Ago
Replies: 12
Views: 508
Posted By Scrutinizer
I think it may be an UTF-16 character. What...

I think it may be an UTF-16 character.

What is the output of the following command on your command line:
locale
Showing results 1 to 25 of 500

 


All times are GMT -4. The time now is 08:01 AM.