Search Results

Search: Posts Made By: SkySmart
Posted By SkySmart
Portable and efficient way to add text after pattern
Shell: sh/bash
OS: Linux (all unix flavors)

Suppose i have a variable with this content:

import os
import sys
MySpecialpath = os.path.abspath(sys.argv[0])
Posted By SkySmart
Optimizing bash loop
now, i have to search for a pattern within a particular time frame which the user will provide in the following format:


it is easy to get tempted to attempt...
Posted By SkySmart
thank you. i intended to put the following in my...
thank you. i intended to put the following in my original code:


but it looks like its not part of what i copied and pasted.

another problem im having is, before and...
Posted By SkySmart
Simple Python Code Question
I have the following code:

#!/usr/bin/env python

mylist = [ "hello", "you", "are", "so", "cool" ]

def printWithoutNewlines():
for objects in mylist:
Posted By SkySmart
Thank you for your patience with me. 1. The...
Thank you for your patience with me.

1. The "RawContent" variable is populated as an output from another program. It is not a file.
2. My mistake. I forgot to include the WrongValue in the...
Posted By SkySmart
My apologies everyone. Below is the...
My apologies everyone.

Below is the content of "RawContent":

## Beginning Stages ##


echo "What is your name? "
read usname


echo "The date and time right now is...
Posted By SkySmart
I really believe i provided more than adequate...
I really believe i provided more than adequate information.

os: all unix oses. linux, sunos, ubuntu, aix
shell: /bin/sh

my apologies for the inconvenience.
Posted By SkySmart
awk code to inspect variable before printing
i have a unique scenario id like help with.

im currently running this command and it does what i want:

printf '%s\n' "${RawContent}" | awk '/## Beginning Stages ##/,/## Ending Stages ##/' |...
Posted By SkySmart
Python: Redirecting to tty and reading from tty
In bash, you can do something like this:

echo -n "What is your name? " > /dev/tty
read thename < /dev/tty

How can I do the same in python?

I have a python script that has the...
Posted By SkySmart
I run a couple of my scripts through pipes and i...
I run a couple of my scripts through pipes and i need to know the terminal from which a script is running.

commands like:

who am i | sh

does not produce the expected terminal address...i.e....
Posted By SkySmart
Redirecting terminal to variable
when i do something like this:

bona=$(echo hi2 > /dev/pts/1 ; printf '%s\n' "" | sed '/^$/d')

i get:


and the $bona variable is empty, when I run:

echo ${bona}

i get the result...
Posted By SkySmart
Bash script unable to disable expected output
I'm trying to understand why a script behaves different when run through a pipe.

My OS:

Linux myip 3.13.0-92-generic #139-Ubuntu SMP Tue Jun 28 20:42:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux...
Posted By SkySmart
Avoid running unnecessary repetitive ps command
i have the following code:

APIDS=$(echo $(ps -ef | awk -v gpid="${gpid}" '$2 == gpid || $3 == gpid {print $2,$3}') | sed 's~ ~|~g')
AllProcs=$(ps -ef | awk -v...
Posted By SkySmart
Efficient way to combine command
im currently running the following command to grab all arguments in front of a script, directly from the process table.

# cat /tmp/allmyprocs
ubuntu 9933 27793 0 03:29 pts/0 00:00:00...
Posted By SkySmart
Avoiding external utilities
under past circumstances, id be fine running commands like this:

case 1:

printf '%s\n' "${MASSIVETEXT}" | egrep "i am on the first line"

case 2:

vprintf '%s\n' "${MASSIVETEXT}" | egrep -v...
Posted By SkySmart
Different ways to check a file
to get the checksum of a file on unix systems, you can just use the "cksum" command.

i discovered there are some watered down versions of unix systems i have to do some work on. surprisingly,...
Posted By SkySmart
How is html code read, compared to say python?
so, the first line of bash, perl, python, ruby, and similar languages must contain the path to the interpreter...i.e. #!/bin/perl, or #!/bin/python. so in the case of a perl script, for instance, a...
Posted By SkySmart
Difference in awk output and while
so, im going over one of my scripts and trying to optimize it.

i have a code like this:

cksum | awk '{prinnt $1$2}'

This does what I need. However, i dont want to call the...
Posted By SkySmart
this works for bash: #!/bin/bash ...
this works for bash:



printf '%s\n' "${DATA}" | while IFS=_ read -a line; do
Posted By SkySmart
Grabbing fields without using external commands

im using the following code to grab the field i want:

cat data | while IFS='_' read v1 v2 v3 v4 v5; do printf '%s\n'...
Posted By SkySmart
the $5 was meant to be $2. I have changed it.
the $5 was meant to be $2. I have changed it.
Posted By SkySmart
Optimize a combination of commands
Im currently running this command to satisfy a particular task. it works for my purposes. but i want to be able to optimize this string of commands and have it be reduced to 1 or 2 commands, if at...
Posted By SkySmart
Replace space within quotes
i have an output that i receive and it looks like this:

echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily Inventory Sync-en-us.csv'...
Posted By SkySmart
this will work on Ubuntu and Redhat systems and...
this will work on Ubuntu and Redhat systems and it is perfect!

are there other similar commands i can use that are more portable?
Posted By SkySmart
thank you so much for the detailed response. ...
thank you so much for the detailed response. what can i look for in the LD_PRELOAD settings? i'll do the scripting. all i need, if you can, is for you to provide me a list of things i should make...
Showing results 1 to 25 of 500


Featured Tech Videos

All times are GMT -4. The time now is 09:04 AM.
Unix & Linux Forums Content Copyright 1993-2019. All Rights Reserved.
Privacy Policy