[Solved] file validation in linux scripting

If you want to do it in pure bash, use the following script: #!/bin/bash while read line; do line=( ${line//[:]/ } ) for i in “${!line[@]}”; do [ ! -z “${line[$i]##*[!0-9]*}” ] && printf “integer” || printf “string” [ “$i” -ne $(( ${#line[@]} – 1)) ] && printf “:” || echo done done < $1 … Read more

[Solved] How to process this text [closed]

You could simply do this through awk, $ awk -F[,-] ‘{var=$1″-“$2; for (i=3;i<=NF;i++){print var”-“$i}}’ file 86-22-63385835 86-22-63385836 86-22-63385933 86-0577-88609993 86-0577-88835386 86-21-58947602 86-21-58947603 0086-755-33186858 0086-755-33186862 0086-755-33186859 2 solved How to process this text [closed]

[Solved] My codes work well In Dev c++ IDE, but in linux terminal, it doesn’t. (especially in the part of ‘while’ loop.) [closed]

You are most likely running into the NL/CR issue. Instead of if (a[i]==””) Use something like: if (isEmptyLine(a[i])) where bool isEmptyLine(std::string const& s) { for ( auto c : s ) { if ( !std::isspace(c) ) return false; } return true; } You can also convert the file into a file with UNIX style line … Read more

[Solved] How do I retrieve the processor time in Linux without function calls?

You should read time(7). Be aware that even written in assembler, your program will be rescheduled at arbitrary moments (perhaps a context switch every millisecond; look also into /proc/interrupts and see proc(5)). Then any hardware timer is meaningless. Even using the RDTSC x86-64 machine instruction to read the hardware timestamp counter is useless (since after … Read more

[Solved] How to get the specific data in a file and direct its output to to new file?

The following awk script should solve your probelm provided you manually add the School heading yourself or if that remains same add it as BEGIN { printf “School” } in below example. $ cat input_file Mark,Texas High, Dallas, k-5 Steve,SA high,Antonio,k-5 Adam,Plano tech,k-5 $ awk -F, ‘BEGIN { sep = “”} { printf(“%s%s”, sep, $2); … Read more

[Solved] Linux and Csharp, Check If File/Folder Doesn’t Exist in Linux, if so, run MKDIR via Csharp SSH – [closed]

This is something I ran into not long ago so trust me on here… Let’s check out this little guy below: if(condition == true) In a way you’re already answering your question, just not comprehending the syntax. (check it out) using System; using System.IO; namespace StackOverflowQA { class Program { static void Main(string[] args) { … Read more

[Solved] memset after malloc [closed]

My guess without a code example is that you were operating on the buffer or struct you malloc’d with assumptions that its contents would be initialized with certain default values. Malloc doesn’t initialize the memory it hands back, so unless you memset or use some other initialization, the values in that memory could be anything, … Read more

[Solved] Running a django project with documentation based in linux on windows

I’m on Windows 10. If you’re not opposed to using Windows Command Prompt, here are the steps to running this project. I don’t use Powershell but if you must, see Powershell note at bottom of my answer. Go here: https://github.com/sajib1066/django-event-management Grab this clone link: https://github.com/sajib1066/django-event-management.git Open Windows CMD prompt. Change directory to a place on … Read more